home *** CD-ROM | disk | FTP | other *** search
Wrap
// Shell.cpp : Defines the class behaviors for the application. // // thread windows #include <process.h> #include "stdafx.h" #include "Shell.h" #include "NewProj.h" #include "htsbase.h" // Ras #if USE_RAS #include "RasLoad.h" #endif #include <afxdisp.h> #include "ras.h" //#include "ShellDoc.h" //#include "ShellView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif // PATCH--> // PATCH--> #include "about.h" #include "infoend.h" // flag de termination int termine=0; int termine_requested=0; int shell_terminated=0; int soft_term_requested=0; FILE* fp_debug=NULL; #include "stdafx.h" #include "Shell.h" #include "process.h" //#include "ShellDoc.h" //#include "ShellView.h" //#include "essai.h" //#include "get.h" //#include "parameter.h" extern "C" { #include "htssystem.h" } #include "Wid1.h" #include "trans.h" #include "InfoUrl.h" //#include "option.h" //#include "filter.h" //#include "wizard.h" // #include "maintab.h" // #include "MemRegister.h" // LANG #include "newlang.h" // PATCH--> //#include "wizard2.h" //#include "WizLinks.h" #include "inprogress.h" #include "SYS\TIMEB.H" // htswrap_add extern "C" { #include "htswrap.h" }; // --- --- --- --- Options --- --- --- --- #define MAX_LEN_INPROGRESS 32 // lancement en multithread du shell ET de gethostbyname #define SHELL_MULTITHREAD 1 //#define HTS_XGMETHOD 2 // 1: AfxBeginThread 2: _beginthread // --- --- --- --- Options --- --- --- --- //int INREDRAW_LOCKED=0; // refresh graphique en cours //int INFILLMEM_LOCKED=0; // refresh mÈmoire en cours int HTTRACK_result=0; // CInfoUrl* _Cinprogress_inst=NULL; extern HICON httrack_icon; /* Main splitter frame */ #include "DialogContainer.h" #include "splitter.h" extern CSplitterFrame* this_CSplitterFrame; /* Main WizTab frame */ #include "WizTab.h" extern CWizTab* this_CWizTab; /* Argh - pas de domodal dans des autres threads ?!?! */ char WIZ_question[1000]; char WIZ_reponse[1000]; // Fonctionnement des THREADS: // // principal ---> robot & refresh data (thread 1) // ---> refresh graphique (thread 2) // GO!> boucle gestion domodal() et boutons // arrÍt: principal demande l'arrÍt (termine_requested) // thread1 active termine et que thread2 ait fini de refresher // thread2 se termine // thread1 retourne 0 ‡ hts_loop // le robot termine // le thread1 active termine, termine le formulaire et se termine // principal ayant quittÈ le formulaire affiche le message de fin // htslib.c extern "C" { HTSEXT_API void qsec2str(char *st,TStamp t); } // construction index gÈnÈral // void Build_TopIndex(); void compute_options() ; char* connversion(char chaine[10000]); void lance(void); int check_continue(char* pathlog); int inprogress_refresh(); //int inprogress_refresh_scan(); void Write_profile(CString path,int load_path); void Read_profile(CString path,int load_path); // dÈja fait mais bon #define HTS_WIN 1 extern "C" { #include "htscore.h" } CString _HTTRACK_VERSION = HTTRACK_VERSION; char LINE[32768]; char OPTIONurl[32000]; char OPTIONfilelist[HTS_URLMAXSIZE*2]; char OPTIONproxy[500]; char OPTIONport[100]; char OPTIONdepth[20]; char OPTIONextdepth[20]; char OPTIONget[10]; //char OPTIONlevel[10]; char OPTIONwhere[8]; char OPTIONmeth[8]; char OPTIONmaxfile[100]; char OPTIONmax[100]; char OPTIONfrag[100]; char OPTIONconn[100]; char OPTIONtog[10]; char OPTIONcache[8]; char OPTIONrobots[8]; char choixdeb[8]; char build[256]; char filtre[32]; char OPTIONhtmlfirst[8]; char OPTIONindex[8]; char OPTIONindex2[8]; char OPTIONdos[8]; char OPTIONtime[20]; char OPTIONrate[20]; char OPTIONhostquit[20]; char OPTIONuser[256]; char OPTIONfooter[256]; char OPTIONlog[8]; char OPTIONtestall[8]; char OPTIONparseall[8]; char OPTIONlink[8]; char OPTIONpath[1000]; char OPTIONretry[16]; char OPTIONerrpage[8]; char OPTIONexternal[8]; char OPTIONnopurge[8]; char OPTIONhidepwd[8]; char OPTIONhidequery[8]; char OPTIONcookies[8]; char OPTIONchecktype[8]; char OPTIONparsejava[8]; char OPTIONCache2[8]; char OPTIONlogtype[8]; char OPTIONnorecatch[8]; char OPTIONtoler[8]; char OPTIONupdhack[8]; char OPTIONhttp10[8]; //--> char OPTIONwaittime[32]; char OPTIONmaxtime[32]; char OPTIONmaxrate[32]; char OPTIONmaxconn[32]; char OPTIONmaxlinks[32]; char OPTIONhh[32]; char OPTIONmm[32]; char OPTIONss[32]; // char buff_filtres[8192]; char buff_MIME[8192]; // RAS char OPTION_RasString[256]; RASDIALPARAMS OPTION_dial; // Fichier tempo FILE* tmpf=NULL; MemRegister tmpm; CNewProj* dialog0=NULL; Wid1* dialog1=NULL; Ctrans* dialog2=NULL; //Coption dialog3; //Cfilter diafiltre; /* wizard diawiz; wizard2 diawiz2; WizLinks diawiz3; */ // CMainTab* maintab=NULL; CShellApp* CShellApp_app=NULL; #include "infoend.h" extern Cinfoend* this_Cinfoend; // PATCH--> Cinprogress* inprogress=NULL; // nbre de slides t_StatsBuffer StatsBuffer[NStatsBuffer]; void* StatsBufferback=NULL; int StatsBufferback_max=0; InpInfo SInfo; #if USE_RAS // Chargement des librairies RAS CDynamicRAS* LibRas=NULL; int LibRasUse=0; // int connected=0; int disconnect=0; HRASCONN conn = NULL; int has_started=0; char connected_err[1000]=""; #endif // pour message final extern char end_mirror_msg[8192]; #include "winhttrack.h" extern CWinHTTrackApp* this_app; // PATCH--> // PATCH--> // FIN PATCH ///////////////////////////////////////////////////////////////////////////// // CShellApp /* BEGIN_MESSAGE_MAP(CShellApp, CWinApp) //{{AFX_MSG_MAP(CShellApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP // Standard file based document commands ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) // Standard print setup command ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) ON_COMMAND(ID_HELP, CWinApp::OnHelp) END_MESSAGE_MAP() */ ///////////////////////////////////////////////////////////////////////////// // CShellApp construction CShellApp::CShellApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CShellApp object //CShellApp theApp; ///////////////////////////////////////////////////////////////////////////// // CShellApp initialization UINT RunBackMirror( LPVOID pP ) { CShellApp_app->init_lance(); return 0; } BOOL LaunchMirror() { WHTT_LOCK(); hts_resetvar(); WHTT_UNLOCK(); AfxBeginThread(RunBackMirror,NULL); return 0; } #if 0 BOOL CShellApp::InitInstance() { CShellApp_app=this; termine=termine_requested=shell_terminated=soft_term_requested=0; // Initialize OLE libraries /* if (!AfxOleInit()) { AfxMessageBox(LANG(LANG_F1)); return FALSE; } AfxEnableControlContainer(); */ // Fixer localisation dans la base de registre //SetRegistryKey("WinHTTrack"); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. /* #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif */ // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. // Change the registry key under which our settings are stored. // You should modify this string to be something appropriate // such as the name of your company or organization. //SetRegistryKey(_T("Local AppWizard-Generated Applications")); //LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. // Parse command line for standard shell commands, DDE, file open /*CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); */ _Cinprogress_inst=NULL; LibRasUse=0; /* #if USE_RAS LibRas=new CDynamicRAS(); if (LibRas->IsRASLoaded()) LibRasUse=1; else LibRasUse=0; #endif */ maintab = new CMainTab("WinHTTrack Website Copier"); // PATCH--> // ÈxÈcution.. init_lance(); delete maintab; maintab=NULL; // PATCH--> /* // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); */ return TRUE; } #endif // PATCH--> // routines diverses char* _SN(LLint n) { static char str[256]; str[0]='\0'; sprintf(str,LLintP,(LLint)n); /* 64-bit */ return str; } // t existe-t-il comme rÈpertoire? int dir_check(char* t) { int dir; FILE* fp=fopen(t,"rb"); dir=(errno==13); // is directory if (fp) fclose(fp); return dir; } void check_temp(char* t,char* s) { if (strlen(s)==0) if (dir_check(t)) strcpybuff(s,t); } // PATCH--> // Routines gestion dials // PatchÈ pour 100% dials void CShellApp::init_lance() { hts_init(); htswrap_add("check-link",httrackengine_check); htswrap_add("init",httrackengine_init); htswrap_add("free",httrackengine_uninit); htswrap_add("start",httrackengine_start); htswrap_add("end",httrackengine_end); htswrap_add("check-html",httrackengine_htmlcheck); htswrap_add("change-options",httrackengine_chopt); htswrap_add("loop",httrackengine_loop); htswrap_add("query",httrackengine_query); htswrap_add("query2",httrackengine_query2); htswrap_add("query3",httrackengine_query3); htswrap_add("pause",httrackengine_pause); termine=termine_requested=shell_terminated=soft_term_requested=0; lance(); // Lancer miroir! if (fp_debug) { fprintf(fp_debug,"Building top index\r\n"); fflush(fp_debug); } Build_TopIndex(); } /* sauver profile */ /* ask: demande confirmation, si cela vaut le coup */ int Save_current_profile(int ask) { CString winprofile; if (ask) { if ((dialog0->GetName().IsEmpty()) && (dialog1->m_urls.IsEmpty())) return IDNO; int r; char msg[256]; sprintf(msg,"%s?\r\n%s",LANG_SAVEPROJECT,dialog0->GetName()); if ((r=AfxMessageBox(msg,MB_YESNOCANCEL)) != IDYES) return r; } // CWaitCursor wait; // sauver whtt { CString st=dialog0->GetBasePath()+dialog0->GetName()+".whtt"; FILE* fp=fopen(st,"wb"); if (fp) fclose(fp); } // sauver ini winprofile=dialog0->GetPath(); if (winprofile.GetLength()>0) if ((winprofile.Right(1)!="/") && (winprofile.Right(1)!="\\")) winprofile+="\\"; winprofile+="hts-cache\\"; { char tempo[HTS_URLMAXSIZE*2]; int i; strcpybuff(tempo,winprofile); for(i=0;i<(int)strlen(tempo);i++) if (tempo[i]=='\\') tempo[i]='/'; structcheck(tempo); } winprofile+="winprofile.ini"; Write_profile(winprofile,0); // marquer document comme "sauvÈ" if (this_CSplitterFrame) this_CSplitterFrame->SetSaved(); return IDYES; } // reprise possible? int check_continue(char* pathlog) { char path_log[256]; strcpybuff(path_log,pathlog); if (strlen(path_log)>0) if ((path_log[strlen(path_log)-1]!='/') && (path_log[strlen(path_log)-1]!='\\')) strcatbuff(path_log,"/"); if ((fexist(fconcat(path_log,"hts-cache/new.dat"))) && (fexist(fconcat(path_log,"hts-cache/new.ndx")))) { // il existe dÈja un cache prÈcÈdent.. renommer //if (fexist(fconcat(path_log,"hts-cache/doit.log"))) { // un cache est prÈsent return 1; //} } if ((fexist(fconcat(path_log,"hts-cache/old.dat"))) && (fexist(fconcat(path_log,"hts-cache/old.ndx")))) { // il existe dÈja un ancien cache prÈcÈdent.. renommer return 1; } AfxMessageBox(LANG(LANG_F2 /*"There is no cache in the directory indicated\nWinHTTrack can not find any interrupted mirror!"*/),MB_OK+MB_ICONSTOP); return 0; } void CShellApp::OptPannel() { Write_profile("<mem>",0); // enregistrer profile dans buffer local if (maintab->DoModal()==IDCANCEL) { Read_profile("<mem>",0); // restaurer } } #define ADD_MIME_IN_COPT(A) \ if(strlen(maintab->m_option11.m_ext##A)+strlen(maintab->m_option11.m_mime##A)) { \ strcatbuff(buff_MIME,"--assume "); \ strcatbuff(buff_MIME,maintab->m_option11.m_ext##A); \ strcatbuff(buff_MIME,"="); \ strcatbuff(buff_MIME,maintab->m_option11.m_mime##A); \ strcatbuff(buff_MIME," "); \ } \ // parser maintab et calculer options void compute_options() { CWaitCursor wait; /* Effacer options */ LINE[0] =OPTIONurl[0] =OPTIONfilelist[0] =OPTIONproxy[0] =OPTIONport[0] =OPTIONdepth[0] =OPTIONextdepth[0] =OPTIONget[0] =OPTIONwhere[0] =OPTIONmeth[0] =OPTIONmaxfile[0] =OPTIONmax[0] =OPTIONfrag[0] =OPTIONconn[0] =OPTIONtog[0] =OPTIONcache[0] =OPTIONrobots[0] =choixdeb[0] =build[0] =filtre[0] =OPTIONindex[0] =OPTIONindex2[0] =OPTIONdos[0] =OPTIONtime[0] =OPTIONrate[0] =OPTIONhostquit[0] =OPTIONuser[0] =OPTIONfooter[0] =OPTIONlog[0] =OPTIONtestall[0] =OPTIONparseall[0] =OPTIONlink[0] =OPTIONpath[0] =OPTIONretry[0] =OPTIONerrpage[0] =OPTIONexternal[0] =OPTIONnopurge[0] =OPTIONhidepwd[0] =OPTIONhidequery[0] =OPTIONcookies[0] =OPTIONchecktype[0] =OPTIONparsejava[0] =OPTIONCache2[0] =OPTIONlogtype[0] =OPTIONnorecatch[0] =OPTIONtoler[0] =OPTIONupdhack[0] =OPTIONhttp10[0] =OPTIONwaittime[0] =OPTIONmaxtime[0] =OPTIONmaxrate[0] =OPTIONmaxconn[0] =OPTIONmaxlinks[0] =OPTIONhh[0] =OPTIONmm[0] =OPTIONss[0] =buff_filtres[0] =buff_MIME[0] =OPTION_RasString[0] ='\0'; /* Effacer options */ // Mode de miroir switch(dialog1->m_todo) { case CB_ERR: case 0: strcpybuff(choixdeb,"w"); break; case 1: strcpybuff(choixdeb,"W"); break; case 2: strcpybuff(choixdeb,"g"); break; case 3: strcpybuff(choixdeb,"Y"); break; case 4: strcpybuff(choixdeb,"!"); break; default: if (dialog1->m_todo==dialog1->LAST_ACTION) strcpybuff(choixdeb,"i"); // reprise else strcpybuff(choixdeb,"/"); // reprise cache prioritaire break; } // URLS char trans[50000]; strcpybuff(trans,""); strncatbuff(trans,dialog1->m_urls,30000); strcpybuff(OPTIONurl,connversion(trans)); // --- formation du path strcpybuff(OPTIONpath,"\""); strcatbuff(OPTIONpath,dialog0->GetPath0()); strcatbuff(OPTIONpath,"\""); strcatbuff(OPTIONpath,","); strcatbuff(OPTIONpath,"\""); strcatbuff(OPTIONpath,dialog0->GetPath0()); strcatbuff(OPTIONpath,"\""); // filelist { CString st=dialog1->m_filelist; st.TrimLeft(); st.TrimRight(); strcpybuff(OPTIONfilelist,st); } // stocker Ètat et hh/mm/ss strcpybuff(OPTIONhh,dialog2->m_hh); strcpybuff(OPTIONmm,dialog2->m_mm); strcpybuff(OPTIONss,dialog2->m_ss); if (strlen(OPTIONhh)) { // heure int x,y,z; sscanf(OPTIONhh,"%d",&x); x=min(max(x,0),23); sprintf(OPTIONhh,"%d",x); // sscanf(OPTIONmm,"%d",&y); y=min(max(y,0),59); sprintf(OPTIONmm,"%d",y); // sscanf(OPTIONss,"%d",&z); z=min(max(z,0),59); sprintf(OPTIONss,"%d",z); // strcpybuff(OPTIONwaittime,""); { char str[32]; strcpybuff(OPTIONwaittime,"#u"); sprintf(str,"%d",x*3600+y*60+z); strcatbuff(OPTIONwaittime,str); } } strcpybuff(OPTION_RasString,dialog2->RasString); OPTION_dial=dialog2->dial; if (choixdeb[0]=='/') { strcpybuff(OPTIONcache,"C1"); // cache prio } else { if(!maintab->m_option3.m_cache) strcpybuff(OPTIONcache,"C0"); else strcpybuff(OPTIONcache,"C2"); // cache non prio //OPTIONcache[0]='\0'; } // ne pas recharger fichiers dÈja pris mais effacÈs if(maintab->m_option9.m_norecatch) strcpybuff(OPTIONnorecatch,"%n"); else strcpybuff(OPTIONnorecatch,""); // proxy strcpybuff(OPTIONproxy,maintab->m_option10.m_proxy); strcpybuff(OPTIONport,maintab->m_option10.m_port); //depth strcpybuff(OPTIONdepth,maintab->m_option5.m_depth); strcpybuff(OPTIONextdepth,maintab->m_option5.m_depth2); if(!maintab->m_option9.m_index) strcpybuff(OPTIONindex,"I0"); else OPTIONindex[0]='\0'; if(!maintab->m_option9.m_index2) strcpybuff(OPTIONindex2,"%I0"); else strcpybuff(OPTIONindex2,"%I"); if(maintab->m_option2.m_dos) strcpybuff(OPTIONdos,"L0"); else OPTIONdos[0]='\0'; if(maintab->m_option2.m_iso9660) strcpybuff(OPTIONdos,"L2"); else OPTIONdos[0]='\0'; if(maintab->m_option1.m_testall) strcpybuff(OPTIONtestall,"t"); else OPTIONtestall[0]='\0'; if(maintab->m_option1.m_parseall) strcpybuff(OPTIONparseall,"%P"); else strcpybuff(OPTIONparseall,"%P0"); if(maintab->m_option1.m_link) strcpybuff(OPTIONlink,"n"); else OPTIONlink[0]='\0'; if(maintab->m_option1.m_htmlfirst) strcpybuff(OPTIONhtmlfirst,"p7"); else strcpybuff(OPTIONhtmlfirst,""); if(maintab->m_option2.m_errpage) strcpybuff(OPTIONerrpage,"o0"); else OPTIONerrpage[0]='\0'; if(maintab->m_option2.m_external) strcpybuff(OPTIONexternal,"x"); else OPTIONexternal[0]='\0'; if(maintab->m_option2.m_nopurge) strcpybuff(OPTIONnopurge,"X0"); else OPTIONnopurge[0]='\0'; if(maintab->m_option2.m_hidepwd) strcpybuff(OPTIONhidepwd,"%x"); else OPTIONhidepwd[0]='\0'; if(maintab->m_option2.m_hidequery) strcpybuff(OPTIONhidequery,"%q0"); else OPTIONhidequery[0]='\0'; OPTIONrobots[0]='\0'; if(maintab->m_option8.m_robots==0) strcpybuff(OPTIONrobots,"s0"); else if(maintab->m_option8.m_robots==1) strcpybuff(OPTIONrobots,"s1"); else if(maintab->m_option8.m_robots==2) strcpybuff(OPTIONrobots,"s2"); // cookies,checktype,parsejava if(maintab->m_option8.m_cookies==0) strcpybuff(OPTIONcookies,"b0"); // else strcpybuff(OPTIONcookies,"b1"); if (maintab->m_option8.m_checktype>=0) sprintf(OPTIONchecktype,"u%d",maintab->m_option8.m_checktype); if(maintab->m_option8.m_parsejava==0) strcpybuff(OPTIONparsejava,"j0"); // else strcpybuff(OPTIONcookies,"j1"); if (maintab->m_option8.m_http10) strcpybuff(OPTIONhttp10,"%h"); // HTTP/1.0 notamment if (maintab->m_option8.m_toler) strcpybuff(OPTIONtoler,"%B"); // tolerent if (maintab->m_option8.m_updhack) strcpybuff(OPTIONupdhack,"%s"); // update hack // store all in cache,logtype if(maintab->m_option9.m_Cache2!=0) strcpybuff(OPTIONCache2,"k"); if(maintab->m_option9.m_logtype==1) strcpybuff(OPTIONlogtype,"z"); else if(maintab->m_option9.m_logtype==2) strcpybuff(OPTIONlogtype,"Z"); if (maintab->m_option3.m_windebug) strcatbuff(OPTIONlogtype,"%H"); // debug headers strcpybuff(build,""); if (maintab->m_option2.m_build==0) strcpybuff(build,"N0"); else if (maintab->m_option2.m_build==1) strcpybuff(build,"N1"); else if (maintab->m_option2.m_build==2) strcpybuff(build,"N2"); else if (maintab->m_option2.m_build==3) strcpybuff(build,"N3"); else if (maintab->m_option2.m_build==4) strcpybuff(build,"N4"); else if (maintab->m_option2.m_build==5) strcpybuff(build,"N5"); else if (maintab->m_option2.m_build==6) strcpybuff(build,"N100"); else if (maintab->m_option2.m_build==7) strcpybuff(build,"N101"); else if (maintab->m_option2.m_build==8) strcpybuff(build,"N102"); else if (maintab->m_option2.m_build==9) strcpybuff(build,"N103"); else if (maintab->m_option2.m_build==10) strcpybuff(build,"N104"); else if (maintab->m_option2.m_build==11) strcpybuff(build,"N105"); else if (maintab->m_option2.m_build==12) strcpybuff(build,"N99"); else if (maintab->m_option2.m_build==13) strcpybuff(build,"N199"); else if (maintab->m_option2.m_build==14) { strcpybuff(build,"-N \""); strcatbuff(build,maintab->m_option2.Bopt.m_BuildString); strcatbuff(build,"\""); } strcpybuff(filtre,""); if (maintab->m_option3.m_filter==0) strcpybuff(filtre,"p0"); else if (maintab->m_option3.m_filter==1) strcpybuff(filtre,"p1"); else if (maintab->m_option3.m_filter==2) strcpybuff(filtre,"p2"); else if (maintab->m_option3.m_filter==3) { /* default */ if(!maintab->m_option1.m_htmlfirst) strcpybuff(filtre,"p3"); } else if (maintab->m_option3.m_filter==4) strcpybuff(filtre,"p7"); // if (maintab->m_option3.m_travel==0) strcatbuff(filtre,"S"); else if (maintab->m_option3.m_travel==1) strcatbuff(filtre,"D"); else if (maintab->m_option3.m_travel==2) strcatbuff(filtre,"U"); else if (maintab->m_option3.m_travel==3) strcatbuff(filtre,"B"); // if (maintab->m_option3.m_travel2==0) strcatbuff(filtre,"a"); else if (maintab->m_option3.m_travel2==1) strcatbuff(filtre,"d"); else if (maintab->m_option3.m_travel2==2) strcatbuff(filtre,"l"); else if (maintab->m_option3.m_travel2==3) strcatbuff(filtre,"e"); // if (maintab->m_option3.m_travel3==0) strcatbuff(filtre,"K0"); else if (maintab->m_option3.m_travel3==1) strcatbuff(filtre,"K"); else if (maintab->m_option3.m_travel3==2) strcatbuff(filtre,"K3"); else if (maintab->m_option3.m_travel3==3) strcatbuff(filtre,"K4"); if (maintab->m_option9.m_logf) strcpybuff(OPTIONlog,"f2"); else strcpybuff(OPTIONlog,"Q"); if(maintab->m_option5.m_sizemax!=""){ strcpybuff(OPTIONmax,"M"); strcatbuff(OPTIONmax,maintab->m_option5.m_sizemax); } else strcpybuff(OPTIONmax,""); if(maintab->m_option5.m_pausebytes!=""){ strcpybuff(OPTIONfrag,"G"); strcatbuff(OPTIONfrag,maintab->m_option5.m_pausebytes); } else strcpybuff(OPTIONfrag,""); if(maintab->m_option5.m_maxhtml!="" || maintab->m_option5.m_othermax!="" ){ strcpybuff(OPTIONmaxfile,"m"); if(maintab->m_option5.m_othermax!="") strcatbuff(OPTIONmaxfile,maintab->m_option5.m_othermax); else strcatbuff(OPTIONmaxfile,"0"); if(maintab->m_option5.m_maxhtml!="") {strcatbuff(OPTIONmaxfile,",");strcatbuff(OPTIONmaxfile,maintab->m_option5.m_maxhtml);} else {strcatbuff(OPTIONmaxfile,",");strcatbuff(OPTIONmaxfile,"0");} } else strcpybuff(OPTIONmaxfile,""); if(strcmp(maintab->m_option4.m_connexion,"")!=0){ strcpybuff(OPTIONconn,"c"); strcatbuff(OPTIONconn,maintab->m_option4.m_connexion); } else strcpybuff(OPTIONconn,""); if(strcmp(maintab->m_option4.m_timeout,"")!=0){ strcpybuff(OPTIONtime,"T"); strcatbuff(OPTIONtime,maintab->m_option4.m_timeout); } else strcpybuff(OPTIONtime,""); // quitter host si timeout ou rate out strcpybuff(OPTIONhostquit,""); { int a=0; if (maintab->m_option4.m_remt) a+=1; if (maintab->m_option4.m_rems) a+=2; sprintf(OPTIONhostquit,"H%d",a); } //--> max time if(strcmp(maintab->m_option5.m_maxtime,"")!=0){ strcpybuff(OPTIONmaxtime,"E"); strcatbuff(OPTIONmaxtime,maintab->m_option5.m_maxtime); } else strcpybuff(OPTIONmaxtime,""); //--> max rate if(strcmp(maintab->m_option5.m_maxrate,"")!=0){ strcpybuff(OPTIONmaxrate,"A"); strcatbuff(OPTIONmaxrate,maintab->m_option5.m_maxrate); } else strcpybuff(OPTIONmaxrate,""); if(strcmp(maintab->m_option5.m_maxconn,"")!=0){ strcpybuff(OPTIONmaxconn,"%c"); strcatbuff(OPTIONmaxconn,maintab->m_option5.m_maxconn); } else strcpybuff(OPTIONmaxconn,""); if(strcmp(maintab->m_option5.m_maxlinks,"")!=0){ strcpybuff(OPTIONmaxlinks,"#L"); strcatbuff(OPTIONmaxlinks,maintab->m_option5.m_maxlinks); } else strcpybuff(OPTIONmaxlinks,""); if(strcmp(maintab->m_option4.m_rate,"")!=0){ strcpybuff(OPTIONrate,"J"); strcatbuff(OPTIONrate,maintab->m_option4.m_rate); } else strcpybuff(OPTIONrate,""); if(strcmp(maintab->m_option6.m_user,"")!=0){ strcpybuff(OPTIONuser,"\""); strcatbuff(OPTIONuser,maintab->m_option6.m_user); strcatbuff(OPTIONuser,"\""); } else strcpybuff(OPTIONuser,""); if(strcmp(maintab->m_option6.m_footer,"")!=0){ strcpybuff(OPTIONfooter,"\""); strcatbuff(OPTIONfooter,maintab->m_option6.m_footer); strcatbuff(OPTIONfooter,"\""); } else strcpybuff(OPTIONfooter,""); if(strcmp(maintab->m_option4.m_retry,"")!=0){ strcpybuff(OPTIONretry,"R"); strcatbuff(OPTIONretry,maintab->m_option4.m_retry); } else strcpybuff(OPTIONretry,""); if(strcmp(maintab->m_option7.m_url2,"")!=0){ strcpybuff(buff_filtres,maintab->m_option7.m_url2); } else strcpybuff(buff_filtres,""); // MIME buff_MIME[0]='\0'; ADD_MIME_IN_COPT(1) ADD_MIME_IN_COPT(2) ADD_MIME_IN_COPT(3) ADD_MIME_IN_COPT(4) ADD_MIME_IN_COPT(5) ADD_MIME_IN_COPT(6) ADD_MIME_IN_COPT(7) ADD_MIME_IN_COPT(8) /* autres options: RAS */ if (dialog2->m_rasdisc) disconnect=1; /* dÈconnexion ‡ la fin */ else disconnect=0; } // Les routines ‡ dÈfinir: int __cdecl httrackengine_check(char* adr,char* fil,int status) { // appelÈ par le wizard return -1; } void __cdecl httrackengine_init() { // appelÈ lors de l'init de HTTRACK, avant le dÈbut d'un miroir #if USE_RAS has_started=0; #endif httrackengine_loop(NULL,0,0,0,0,NULL,0); // init //printf("DEMARRAGE DU MIROIR DETECTE\n"); } void __cdecl httrackengine_uninit() { // appelÈ en fin de miroir (peut Ítre utile!!!) #if USE_RAS if (LibRasUse) { /* librairie RAS chargÈe */ if (disconnect) { /* on doit dÈconnecter */ if (connected) { /* on a initiÈ une connexion */ if (conn) LibRas->RasHangUp(conn); } else { /* tout dÈconnecter */ // On coupe tout (non, pas bourrin) DWORD size; RASCONN* adr; int count=256; size = sizeof(RASCONN)*(count+2); adr = (RASCONN*) (char*) calloc(size,1); if (adr) { DWORD ent; int i; for(i=0;i<count;i++) { adr[i].dwSize=sizeof(RASCONN); strcpybuff(adr[i].szEntryName,""); } if (LibRas->RasEnumConnections((RASCONN*) adr,&size,&ent) == 0) { for(i=0;i<(int)ent;i++) { LibRas->RasHangUp(adr[i].hrasconn); } } free(adr); } } } } #endif } int __cdecl httrackengine_start(void* dummy) { // appelÈ lors du dÈmarrage du miroir (premiËres requËtes) #if USE_RAS // connexion RAS has_started=1; // dÈmarrage connected=0; conn = NULL; memset(&SInfo, 0, sizeof(SInfo)); if (LibRasUse) { if (strlen(OPTION_RasString)>0) { // sÈlection provider if (!LibRas->RasDial(NULL,NULL,&OPTION_dial,NULL,NULL,&conn)) { RASCONNSTATUS status; do { status.dwSize = sizeof(status); LibRas->RasGetConnectStatus(conn,&status); switch(status.rasconnstate) { case RASCS_Connected : connected=1; break; case RASCS_Disconnected : strcpybuff(connected_err,LANG(LANG_F3 /*"Could not connect to provider"*/)); connected=-1; break; } } while(connected==0); } else { strcpybuff(connected_err,LANG(LANG_F3 /*"Could not connect to provider","Impossible d'Ètablir la connexion"*/)); connected=-1; //termine=1; } } // if (connected != -1) // si pas d'erreur RAS return 1; else return 0; } else return 1; #else return 1; #endif } int httrackengine_end() { // appelÈ lors de la fin du miroir (plus de liens ‡ charger) WHTT_LOCK(); termine=1; if (_Cinprogress_inst) { _Cinprogress_inst->EndDialog(IDOK); _Cinprogress_inst=NULL; } WHTT_UNLOCK(); return 1; } int __cdecl httrackengine_htmlcheck(char* html,int len,char* url_adresse,char* url_fichier) { // appelÈ ‡ chaque fois qu'un html doit Ítre scannÈ (utile pour la prospection mais inutile ici) return 1; } int __cdecl httrackengine_chopt(void* opt) { return 1; } // Le routine la plus utile sans doute: elle refresh les tableaux // C'est la 2e routine en thread qui assure le refresh graphique // (plus efficace) // -->C'est elle qui dÈcide de tout arrÍter si elle dÈtecte in termine_request<-- int __cdecl httrackengine_loop( void* _back,int back_max,int back_index, int lien_n,int lien_tot, int stat_time, hts_stat_struct* stats) { // appelÈ ‡ chaque boucle de HTTrack static char s[HTS_URLMAXSIZE*2]=""; // utilisÈ plus loin int stat_written=-1; int stat_updated=-1; int stat_errors=-1; int stat_warnings=-1; int stat_infos=-1; int nbk=-1; LLint nb=-1; int stat_nsocket=-1; LLint stat_bytes=-1; LLint stat_bytes_recv=-1; int irate=-1; WHTT_LOCK(); if (stats) { stat_written=stats->stat_files; stat_updated=stats->stat_updated_files; stat_errors=stats->stat_errors; stat_warnings=stats->stat_warnings; stat_infos=stats->stat_infos; nbk=stats->nbk; stat_nsocket=stats->stat_nsocket; irate=(int)stats->rate; nb=stats->nb; stat_bytes=stats->nb; stat_bytes_recv=stats->HTS_TOTAL_RECV; } #if !SHELL_MULTITHREAD static TStamp last_time; #endif int rate; // casts lien_back* back=(lien_back*) _back; // static int ft=-1; if (back_max == 0) { #if !SHELL_MULTITHREAD last_time=0; #endif // en cas de manque de time SInfo.stat_timestart=time_local(); WHTT_UNLOCK(); return 1; } if ((termine) || (termine_requested)) { SInfo.refresh=0; // pas de refresh SInfo.refresh=0; // pas de refresh termine_requested=1; WHTT_UNLOCK(); return 0; } if (stat_written>=0) SInfo.stat_written=stat_written; if (stat_updated>=0) SInfo.stat_updated=stat_updated; if (stat_errors>=0) SInfo.stat_errors=stat_errors; if (stat_warnings>=0) SInfo.stat_warnings=stat_warnings; if (stat_infos>=0) SInfo.stat_infos=stat_infos; #if SHELL_MULTITHREAD //if (((tl-last_time)>=100) || ((tl-last_time)<0)) { // chaque 100 ms if (SInfo.ask_refresh) { #else TStamp tl=0; { time_t tt; struct tm* A; tt=time(NULL); A=localtime(&tt); tl+=A->tm_sec; tl+=A->tm_min*60; tl+=A->tm_hour*60*60; //tl+=A->tm_yday*60*60*24; //tl+=A->tm_year*60*60*24*365; tl*=1000; // en ms struct _timeb timebuffer; char *timeline; _ftime( &timebuffer ); timeline = ctime( & ( timebuffer.time ) ); tl+=timebuffer.millitm; // + ms } if (((tl-last_time)>=HTS_SLEEP_WIN) || ((tl-last_time)<0)) { // chaque 250 ms last_time=tl; #endif //INFILLMEM_LOCKED=1; // locker interface // OPTI int rate; SInfo.ask_refresh=0; // pour Èviter temps cpu consommÈ trop grand // Sleep(10); // initialiser ft if ((stat_nsocket==-1)) { if (SInfo.ft==-1) { SInfo.ft=stat_time; } } #if !SHELL_MULTITHREAD // MSG msg; if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE )) { switch (msg.message) { case WM_COMMAND: switch(msg.wParam) { case ID_APP_ABOUT: { Cabout about; about.DoModal(); } break; case ID_APP_EXIT: case WM_CLOSE : termine_requested=1; break; case WM_DESTROY: case WM_NCDESTROY: termine_requested=1; break; } break; default: DefWindowProc(msg.hwnd,msg.message,msg.wParam,msg.lParam); break; } } // #endif // calculer heure si ce n'est dÈja fait if (stat_time<0) SInfo.stat_time=(int) (time_local()-SInfo.stat_timestart); // calculer transfer rate if ((stat_time>0) && (stat_bytes_recv>0)) rate=(int)(stat_bytes_recv/stat_time); else rate=0; // pas d'infos // stocker infos: octets transfÈrÈs, temps, etc. if (stat_bytes>=0) SInfo.stat_bytes=stat_bytes; // bytes if (stat_time>=0) SInfo.stat_time=stat_time; // time if (lien_tot>=0) SInfo.lien_tot=lien_tot; // nb liens if (lien_n>=0) SInfo.lien_n=lien_n; // scanned SInfo.stat_nsocket=stat_nsocket; // socks if (rate>0) SInfo.rate=rate; // rate if (irate>=0) SInfo.irate=irate; // irate if (SInfo.irate<0) SInfo.irate=SInfo.rate; if (SInfo.stat_back>=0) SInfo.stat_back=nbk; // back: tableau de back_max ÈlÈments de cache // back_max: nombre d'ÈlÈments ^^^^ // lien_tot: nombre total de liens traitÈs pour le moment // stat_bytes: octets sauvegardÈs // stat_bytes_recv: octets tÈlÈchargÈs // stat_time: temps en seconde depuis le dÈbut du miroir // stat_nsocket: nombre de sockets connectÈes actuellement // on peut en dÈduire rate=stat_bytes_recv/stat_time // printf("loop.. %d liens, %d octets, %d secondes, %d sockets, TAUX=%d\n",lien_tot,stat_bytes,stat_time,stat_nsocket,rate); // parcourir registre des liens if (back_index>=0) { // seulement si index passÈ int j,k; int index=0; int ok=0; // idem int l; // idem int M=32; // idem StatsBufferback=(void*) back; StatsBufferback_max=back_max; { int i; for(i=0;i<NStatsBuffer;i++) { strcpybuff(StatsBuffer[i].etat,""); strcpybuff(StatsBuffer[i].nom,""); strcpybuff(StatsBuffer[i].fichier,""); strcpybuff(StatsBuffer[i].url_sav,""); StatsBuffer[i].back=NULL; StatsBuffer[i].size=0; StatsBuffer[i].sizetot=0; } } for(k=0;k<2;k++) { // 0: lien en cours 1: autres liens for(j=0;(j<3) && (index<NStatsBuffer);j++) { // passe de prioritÈ int _i; for(_i=0+k;(_i< max(back_max*k,1) ) && (index<NStatsBuffer);_i++) { // no lien int i=(back_index+_i)%back_max; // commencer par le "premier" (l'actuel) if (back[i].status>=0) { // signifie "lien actif" // int ok=0; // OPTI ok=0; switch(j) { case 0: // prioritaire if ((back[i].status>0) && (back[i].status<99)) { strcpybuff(StatsBuffer[index].etat,LANG(LANG_F4 /*"receive","rÈception"*/)); ok=1; } break; case 1: if (back[i].status==99) { strcpybuff(StatsBuffer[index].etat,LANG(LANG_F5 /*"request","requËte"*/)); ok=1; } else if (back[i].status==100) { strcpybuff(StatsBuffer[index].etat,LANG(LANG_F6 /*"connect","connexion"*/)); ok=1; } else if (back[i].status==101) { strcpybuff(StatsBuffer[index].etat,LANG(LANG_F7 /*"search","recherche"*/)); ok=1; } else if (back[i].status==1000) { // ohh le beau ftp sprintf(StatsBuffer[index].etat,"ftp: %s",back[i].info); ok=1; } else if (back[i].status==102) { // SSL handshake strcpybuff(StatsBuffer[index].etat,LANG(LANG_F6 /*"connect","connexion"*/)); ok=1; } break; default: if (back[i].status==0) { // prÍt if ((back[i].r.statuscode==200)) { strcpybuff(StatsBuffer[index].etat,LANG(LANG_F8 /*"ready","prÍt"*/)); ok=1; } else if ((back[i].r.statuscode>=100) && (back[i].r.statuscode<=599)) { char tempo[256]; tempo[0]='\0'; infostatuscode(tempo,back[i].r.statuscode); strcpybuff(StatsBuffer[index].etat,tempo); ok=1; } else { strcpybuff(StatsBuffer[index].etat,LANG(LANG_F9 /*"error","erreur"*/)); ok=1; } } break; } if (ok) { // OPTI int l; // OPTI int M=32; // longueur // OPTI char s[HTS_URLMAXSIZE*2]=""; // StatsBuffer[index].back=i; // index pour + d'infos // s[0]='\0'; strcpybuff(StatsBuffer[index].url_sav,back[i].url_sav); // pour cancel if (strcmp(back[i].url_adr,"file://")) strcatbuff(s,back[i].url_adr); else strcatbuff(s,"localhost"); if (back[i].url_fil[0]!='/') strcatbuff(s,"/"); strcatbuff(s,back[i].url_fil); StatsBuffer[index].fichier[0]='\0'; { char* a=strrchr(s,'/'); if (a) { strncatbuff(StatsBuffer[index].fichier,a,200); *a='\0'; } } if ((l=strlen(s))<MAX_LEN_INPROGRESS) strcpybuff(StatsBuffer[index].nom,s); else { // couper StatsBuffer[index].nom[0]='\0'; strncatbuff(StatsBuffer[index].nom,s,MAX_LEN_INPROGRESS/2-2); strcatbuff(StatsBuffer[index].nom,"..."); strcatbuff(StatsBuffer[index].nom,s+l-MAX_LEN_INPROGRESS/2+2); } //if (back[i].url_fil[0]!='/') printf("/"); if (back[i].r.totalsize>0) { // taille prÈdÈfinie StatsBuffer[index].sizetot=back[i].r.totalsize; StatsBuffer[index].size=back[i].r.size; } else { // pas de taille prÈdÈfinie if (back[i].status==0) { // prÍt StatsBuffer[index].sizetot=back[i].r.size; StatsBuffer[index].size=back[i].r.size; } else { StatsBuffer[index].sizetot=8192; StatsBuffer[index].size=(back[i].r.size % 8192); } } index++; } } } } } } #if SHELL_MULTITHREAD SInfo.refresh=1; // on signale qu'il faut faire un refresh! #else inprogress_refresh(); // tout de suite (non multithread) #endif // INFILLMEM_LOCKED=0; // dÈlocker interface } WHTT_UNLOCK(); return (termine==0); } int inprogress_refresh() { static int toggle=0; // WHTT_LOCK(); // deja fait if ((!termine) && (!termine_requested) && (inprogress->m_hWnd)) { if (SInfo.refresh) { // INREDRAW_LOCKED=1; // REFRESH (si nb de socket==-1 on manage les fenetres) int icn; icn=inprogress->IsIconic(); CString lnk; if (SInfo.stat_back) lnk.Format("%d/%d (+%d)",SInfo.lien_n,SInfo.lien_tot-1,SInfo.stat_back); else lnk.Format("%d/%d",SInfo.lien_n,SInfo.lien_tot-1); if (!icn) { int parsing=0; if (!soft_term_requested) { if (!hts_setpause(-1)) { if (!(parsing=hts_is_parsing(-1))) inprogress->SetDlgItemText(IDC_inforun,LANG(LANG_F10 /*"Receiving files.","RÈception des fichiers"*/)); else { switch(hts_is_testing()) { case 0: inprogress->SetDlgItemText(IDC_inforun,LANG(LANG_F11 /*"Parsing HTML file..","Parcours du fichier HTML"*/)); break; case 1: inprogress->SetDlgItemText(IDC_inforun,LANG(LANG_F12 /*"Parsing HTML file (testing links)..","Parcours du fichier HTML (test des liens)"*/)); break; case 2: inprogress->SetDlgItemText(IDC_inforun,LANG(LANG_F11b)); break; } } } else { if (((toggle++)/5)%2) inprogress->SetDlgItemText(IDC_inforun,LANG(LANG_F13 /*"Paused (select [File]/[Pause transfer] to continue)","Interrompu (choisir [Fichier]/[Interrompre transferts] pour continuer)"*/)); else inprogress->SetDlgItemText(IDC_inforun,""); } } else { if (((toggle++)/5)%2) inprogress->SetDlgItemText(IDC_inforun,LANG(LANG_F13b)); else inprogress->SetDlgItemText(IDC_inforun,""); } if (SInfo.stat_time>0) { char s[256]; qsec2str(s,(TStamp) SInfo.stat_time); inprogress->SetDlgItemText(IDC_i1 ,s); // time } else inprogress->SetDlgItemText(IDC_i1 , _SN(SInfo.stat_time) ); // time inprogress->SetDlgItemText(IDC_i0 , int2bytes(SInfo.stat_bytes) ); // bytes inprogress->SetDlgItemText(IDC_i2 , lnk); // scanned if (SInfo.stat_nsocket>0) inprogress->SetDlgItemText(IDC_i3 , _SN(SInfo.stat_nsocket) ); // socks else inprogress->SetDlgItemText(IDC_i3 , "none" ); // wait CString st; st.Format("%s (%s)",int2bytessec(SInfo.irate),int2bytessec(SInfo.rate)); inprogress->SetDlgItemText(IDC_i4 , st ); // rate inprogress->SetDlgItemText(IDC_i5 , _SN(SInfo.stat_errors) ); inprogress->SetDlgItemText(IDC_i6 , _SN(SInfo.stat_written) ); { char tempo[256]; int pc=0; if (SInfo.stat_written) pc=(int)((SInfo.stat_updated*100)/(SInfo.stat_written)); if (pc) sprintf(tempo,"%d (%d%%)",SInfo.stat_updated,pc); else sprintf(tempo,"%d",SInfo.stat_updated); inprogress->SetDlgItemText(IDC_i7 , tempo ); } /*if (!parsing)*/ { { int i; for(i=0;i<NStatsBuffer;i++) { if (StatsBuffer[i].sizetot>0) { TStamp d = ((TStamp) StatsBuffer[i].size * 1000); d = d / ((TStamp) StatsBuffer[i].sizetot); StatsBuffer[i].offset = (int) d; } else StatsBuffer[i].offset = 0; } } if (!parsing) inprogress->m_sl0.SetRange(0,1000); inprogress->m_sl1.SetRange(0,1000); inprogress->m_sl2.SetRange(0,1000); inprogress->m_sl3.SetRange(0,1000); inprogress->m_sl4.SetRange(0,1000); inprogress->m_sl5.SetRange(0,1000); inprogress->m_sl6.SetRange(0,1000); inprogress->m_sl7.SetRange(0,1000); inprogress->m_sl8.SetRange(0,1000); inprogress->m_sl9.SetRange(0,1000); inprogress->m_sl10.SetRange(0,1000); inprogress->m_sl11.SetRange(0,1000); inprogress->m_sl12.SetRange(0,1000); inprogress->m_sl13.SetRange(0,1000); if (!parsing) inprogress->m_sl0.SetPos(StatsBuffer[0].offset); inprogress->m_sl1.SetPos(StatsBuffer[1].offset); inprogress->m_sl2.SetPos(StatsBuffer[2].offset); inprogress->m_sl3.SetPos(StatsBuffer[3].offset); inprogress->m_sl4.SetPos(StatsBuffer[4].offset); inprogress->m_sl5.SetPos(StatsBuffer[5].offset); inprogress->m_sl6.SetPos(StatsBuffer[6].offset); inprogress->m_sl7.SetPos(StatsBuffer[7].offset); inprogress->m_sl8.SetPos(StatsBuffer[8].offset); inprogress->m_sl9.SetPos(StatsBuffer[9].offset); inprogress->m_sl10.SetPos(StatsBuffer[10].offset); inprogress->m_sl11.SetPos(StatsBuffer[11].offset); inprogress->m_sl12.SetPos(StatsBuffer[12].offset); inprogress->m_sl13.SetPos(StatsBuffer[13].offset); // redraw en boucle { int i=0; if (parsing) i++; for( ; i<NStatsBuffer;i++) { inprogress->element[0][i]->SetWindowText(StatsBuffer[i].etat); inprogress->element[1][i]->SetWindowText(StatsBuffer[i].nom); inprogress->element[4][i]->SetWindowText(StatsBuffer[i].fichier); if ((strlen(StatsBuffer[i].etat)==0) != StatsBuffer[i].actived) { StatsBuffer[i].actived=!StatsBuffer[i].actived; if (!StatsBuffer[i].actived) inprogress->element[3][i]->ModifyStyle(WS_DISABLED,0); else inprogress->element[3][i]->ModifyStyle(0,WS_DISABLED); inprogress->element[3][i]->RedrawWindow(); } } } // } /* else*/ if (parsing) { // parsing // inprogress->m_sl0.SetRange(0,100); inprogress->m_sl0.SetPos(parsing); inprogress->element[0][0]->SetWindowText(LANG(LANG_F14 /*"scanning","parcours"*/)); inprogress->element[1][0]->SetWindowText(StatsBuffer[0].nom); inprogress->element[4][0]->SetWindowText(""); //inprogress->element[0][1]->SetWindowText(); } } { static char last_info[256]=""; char info[256]; if ((SInfo.stat_nsocket==-1)) { #if USE_RAS if (!has_started) #endif inprogress->SetDlgItemText(IDC_nm0,LANG(LANG_F15 /*"Waiting for specific hour to start","Attente de l'heure programmÈe pour dÈmarrer"*/)); #if USE_RAS else inprogress->SetDlgItemText(IDC_nm0,LANG(LANG_F16 /*"Connecting to provider","Connexion au provider"*/)); #endif inprogress->m_sl0.SetRange(0,SInfo.ft); inprogress->m_sl0.SetPos(SInfo.ft-SInfo.stat_time); // temps restant // inprogress->SetDlgItemText(IDC_nm1,_SN(ft)); if (icn && (!this_CSplitterFrame->iconifie)) { // minimisÈe mais pas en icone sprintf(info,"[%d s]",SInfo.stat_time); } else { sprintf(info,LANG(LANG_F17 /*"Mirror waiting [%d seconds]","Miroir en attente [%d secondes]"*/),SInfo.stat_time); } } else { if (icn) { // minimisÈe sprintf(info,"[%s]",lnk); } else { sprintf(info,LANG(LANG_F18 /*"Mirror in progress [%s, %d bytes]","Miroir en cours [%s, %d octets]"*/),lnk,SInfo.stat_bytes); } } if (strcmp(info,last_info)) { /* a changÈ */ strcpybuff(last_info,info); /* recopier */ if (this_CSplitterFrame->iconifie) // minimisÈ icone this_CSplitterFrame->IconChange(last_info); else this_app->GetMainWnd()->SetWindowText(last_info); } } //inprogress->UpdateWindow(); } else { } } // WHTT_UNLOCK(); return 1; } /* // refresh scan int inprogress_refresh_scan() { if ((!termine) && (!termine_requested) && (inprogress->m_hWnd)) { if (!SInfo.refresh) { if (!inprogress->IsIconic()) { int n; // patch pour le scanning if (n=hts_is_parsing()) { strcpybuff(StatsBuffer[0].etat,"scanning"); inprogress->element[0][0]->SetWindowText("scanning"); StatsBuffer[0].sizetot=100; StatsBuffer[0].size=n; inprogress->m_sl0.SetRange(0,100); // progression en % du scanning inprogress->m_sl0.SetPos(n); //} else { // inprogress->element[0][0]->SetWindowText("..."); } } } } return 1; } */ /* Plantages si DoModal() dans un thread != du principal.. passons.. */ char* __cdecl httrackengine_query(char* question) { strcpybuff(WIZ_question,question); AfxGetMainWnd()->SendMessage(WM_COMMAND,wm_WizRequest1,0); return WIZ_reponse; } char* __cdecl httrackengine_query2(char* question) { strcpybuff(WIZ_question,question); AfxGetMainWnd()->SendMessage(WM_COMMAND,wm_WizRequest2,0); return WIZ_reponse; } char* __cdecl httrackengine_query3(char* question) { strcpybuff(WIZ_question,question); AfxGetMainWnd()->SendMessage(WM_COMMAND,wm_WizRequest3,0); return WIZ_reponse; } void __cdecl httrackengine_pause(char* lockfile) { AfxMessageBox("Engine paused.. click OK to continue!",MB_OK); remove(lockfile); } // modif RX 10/10/98 pour gestion des , et des tabs char* connversion(char* chaine) { for(int i=0;i < (int) strlen(chaine);i++) if(chaine[i]=='\n') chaine[i]=' '; else if(chaine[i]==13) chaine[i]=' '; else if(chaine[i]==9) chaine[i]=' '; /*else if(chaine[i]==',') chaine[i]=' ';*/ return chaine; } #if SHELL_MULTITHREAD void __cdecl RunBackRobot(void* al_p) { int argc; char** argv; while((!inprogress) && (!termine)) Sleep(10); if (inprogress) while ((!inprogress->m_hWnd) || (termine)) Sleep(10); // attendre formulaire //Sleep(100); Robot_params* al=(Robot_params*) al_p; argc = al->argc; argv = al->argv; /* launch the engine */ hts_init(); HTTRACK_result=hts_main(argc,argv); /* clear all vars */ WHTT_LOCK(); termine=1; WHTT_UNLOCK(); hts_uninit(); _endthread(); } #endif // modifs RX 10/10/98: gestion des , CString change(char* chaine,char c) { int comma=1; int first=1; CString chaine1; for(int i=0;i < (int) strlen(chaine);i++) { switch(chaine[i]) { case 10: case 13: case 9: case ' ': case ',': comma=1; break; default: if (comma) { if (!first) chaine1 +=' '; else first=0; chaine1 +=c; comma=0; } chaine1 += chaine[i]; break; } } return chaine1; } // Lancement void lance(void) { char *argv[1999]; int argc=1; int g=0; int i =0; // if (fp_debug) { fprintf(fp_debug,"Building command line\r\n"); fflush(fp_debug); } // LINE[0]='\0'; strcpybuff(LINE,"-"); if (choixdeb[0]!='W') strcatbuff(LINE,"q"); // quiet if (choixdeb[0]=='/') strcatbuff(LINE,"i"); else if (choixdeb[0]!='!') strcatbuff(LINE,choixdeb); // option de profondeur if(strcmp(OPTIONdepth,"")!=0) { strcatbuff(LINE,"r"); strcatbuff(LINE,OPTIONdepth); } if(strcmp(OPTIONextdepth,"")!=0) { strcatbuff(LINE,"%e"); strcatbuff(LINE,OPTIONextdepth); } if(strcmp(OPTIONcache,"")!=0) strcatbuff(LINE,OPTIONcache); if(strcmp(OPTIONnorecatch,"")!=0) strcatbuff(LINE,OPTIONnorecatch); if(strcmp(OPTIONtestall,"")!=0) strcatbuff(LINE,OPTIONtestall); if(strcmp(OPTIONparseall,"")!=0) strcatbuff(LINE,OPTIONparseall); if(strcmp(OPTIONlink,"")!=0) strcatbuff(LINE,OPTIONlink); if(strcmp(OPTIONexternal,"")!=0) strcatbuff(LINE,OPTIONexternal); if(strcmp(OPTIONnopurge,"")!=0) strcatbuff(LINE,OPTIONnopurge); if(strcmp(OPTIONhidepwd,"")!=0) strcatbuff(LINE,OPTIONhidepwd); if(strcmp(OPTIONhidequery,"")!=0) strcatbuff(LINE,OPTIONhidequery); if(strcmp(OPTIONrobots,"")!=0) strcatbuff(LINE,OPTIONrobots); if(strcmp(OPTIONcookies,"")!=0) strcatbuff(LINE,OPTIONcookies); if(strcmp(OPTIONchecktype,"")!=0) strcatbuff(LINE,OPTIONchecktype); if(strcmp(OPTIONparsejava,"")!=0) strcatbuff(LINE,OPTIONparsejava); if(strcmp(OPTIONCache2,"")!=0) strcatbuff(LINE,OPTIONCache2); if(strcmp(OPTIONlogtype,"")!=0) strcatbuff(LINE,OPTIONlogtype); if (strlen(OPTIONhttp10)) strcatbuff(LINE,OPTIONhttp10); if (strlen(OPTIONtoler)) strcatbuff(LINE,OPTIONtoler); if (strlen(OPTIONupdhack)) strcatbuff(LINE,OPTIONupdhack); // si get, ne pas faire if (strcmp(choixdeb,"g")!=0) { if(build[0]=='-') { strcatbuff(LINE," "); strcatbuff(LINE,build); strcatbuff(LINE," -"); } else if (strcmp(build,"")!=0) strcatbuff(LINE,build); } strcatbuff(LINE,OPTIONdos); strcatbuff(LINE,OPTIONindex); strcatbuff(LINE,OPTIONindex2); strcatbuff(LINE,OPTIONhtmlfirst); strcatbuff(LINE,filtre); strcatbuff(LINE,OPTIONmax); strcatbuff(LINE,OPTIONfrag); strcatbuff(LINE,OPTIONmaxfile); strcatbuff(LINE,OPTIONconn); strcatbuff(LINE,OPTIONtime); strcatbuff(LINE,OPTIONrate); strcatbuff(LINE,OPTIONretry); strcatbuff(LINE,OPTIONhostquit); strcatbuff(LINE,OPTIONlog); strcatbuff(LINE,OPTIONerrpage); //--> strcatbuff(LINE,OPTIONwaittime); strcatbuff(LINE,OPTIONmaxtime); strcatbuff(LINE,OPTIONmaxrate); strcatbuff(LINE,OPTIONmaxconn); strcatbuff(LINE,OPTIONmaxlinks); strcatbuff(LINE,"#f"); // flush if (strcmp(OPTIONuser,"")!=0) {strcatbuff(LINE," ");strcatbuff(LINE,"-F");strcatbuff(LINE," ");strcatbuff(LINE,OPTIONuser);} if (strcmp(OPTIONfooter,"")!=0) {strcatbuff(LINE," ");strcatbuff(LINE,"-%F");strcatbuff(LINE," ");strcatbuff(LINE,OPTIONfooter);} if ((int)strlen(OPTIONproxy)>0) { strcatbuff(LINE," -P "); strcatbuff(LINE,OPTIONproxy); strcatbuff(LINE,":"); strcatbuff(LINE,OPTIONport); } if (strnotempty(LANGUAGE_ISO)) { strcatbuff(LINE," -%l \""); strcatbuff(LINE,LANGUAGE_ISO); if (strcmp(LANGUAGE_ISO,"en")!=0) strcatbuff(LINE,", en"); strcatbuff(LINE,", *\""); } // mode spider, mettre aprËs options if (choixdeb[0]=='!') { strcatbuff(LINE," --testlinks"); } else if (choixdeb[0]=='Y') { strcatbuff(LINE," --mirrorlinks"); } // URLs!! strcatbuff(LINE," "); strcatbuff(LINE,OPTIONurl); // file list if ((int) strlen(OPTIONfilelist)>0) { strcatbuff(LINE," -%L \""); strcatbuff(LINE,OPTIONfilelist); strcatbuff(LINE,"\""); } // chemins if(strcmp(OPTIONpath,"")!=0) { strcatbuff(LINE," "); strcatbuff(LINE,"-O"); strcatbuff(LINE," "); strcatbuff(LINE,OPTIONpath); } // buffer -> les + et - if(strcmp(buff_filtres,"")!=0) { //if(strcmp(diafiltre.m_url2 ,"")!=0) { strcatbuff(LINE," "); strcatbuff(LINE,buff_filtres ); } // --assume if (strnotempty(buff_MIME)) { strcatbuff(LINE," "); strcatbuff(LINE,buff_MIME ); } // --- // if (fp_debug) { fprintf(fp_debug,"Cleaning up command line and counting parameters\r\n"); fflush(fp_debug); } // // Èpurer cr,lf,tab - double espace -> espace { char *a; while(a=strchr(LINE,9)) *a=' '; while(a=strchr(LINE,10)) *a=' '; while(a=strchr(LINE,13)) *a=' '; } char LINE_back[65535]; strcpybuff(LINE_back,LINE); // couper en morceaux { char* p=LINE; argv[0]="winhttrack"; do { argv[argc++]=p; p=next_token(p,0); // prochain token if (p) { *p=0; // octet nul (tableau) p++; } } while(p!=NULL); } // if (fp_debug) { fprintf(fp_debug,"Checking doit.log\r\n"); fflush(fp_debug); } // // Ok, on lance! if(!termine) { int result=0; { char path_log[HTS_URLMAXSIZE*2]; strcpybuff(path_log,CShellApp_app->end_path_complete); if (strlen(path_log)>0) if ((path_log[strlen(path_log)-1]!='/') && (path_log[strlen(path_log)-1]!='\\')) strcatbuff(path_log,"/"); // on efface le doit.log, pour annuler les parametres anciens et en redÈfinir de nouveaux // c'est ici une logique qui diffËre de la version en ligne de commande //if ((fexist(fconcat(path_log,"hts-cache/new.dat"))) && (fexist(fconcat(path_log,"hts-cache/new.ndx")))) { // il existe dÈja un cache prÈcÈdent.. renommer if (fexist(fconcat(path_log,"hts-cache/new.ndx"))) { // un cache est prÈsent if (fexist(fconcat(path_log,"hts-cache/doit.log"))) remove(fconcat(path_log,"hts-cache/doit.log")); FILE* fp=fopen(fconcat(path_log,"hts-cache/doit.log"),"wb"); if (fp) fclose(fp); } //} } // --- // LANCER LE MIROIR // --- // if (fp_debug) { fprintf(fp_debug,"Ready to call httrack engine, launching threads\r\n"); fflush(fp_debug); } // #if SHELL_MULTITHREAD Robot_params al; al.argc=argc; al.argv=argv; _beginthread( RunBackRobot , 0, (void*) &al); //_beginthread( RefreshBackRobot , 0, NULL); // if (fp_debug) { fprintf(fp_debug,"Threads launched, displaying main dialog\r\n"); fflush(fp_debug); } // // domodal du refresh /* XXC A SUPPRIMER */ while(!termine) { Sleep(100); } //inprogress->DoModal(); WHTT_LOCK(); shell_terminated=1; result=HTTRACK_result; termine=1; WHTT_UNLOCK(); // if (fp_debug) { fprintf(fp_debug,"Main dialog exited\r\n"); fflush(fp_debug); } // // non multithread #else #error "Non supportÈ" #endif /* Aborted mirror or finished? */ { char path_log[HTS_URLMAXSIZE*2]; strcpybuff(path_log,CShellApp_app->end_path_complete); if (strlen(path_log)>0) if ((path_log[strlen(path_log)-1]!='/') && (path_log[strlen(path_log)-1]!='\\')) strcatbuff(path_log,"/"); if (soft_term_requested || termine_requested) { FILE* fp=fopen(fconcat(path_log,"hts-cache/interrupted.lock"),"wb"); if (fp) fclose(fp); } else remove(fconcat(path_log,"hts-cache/interrupted.lock")); } //SetForegroundWindow(); // yop en premier plan! // if (fp_debug) { fprintf(fp_debug,"Displaying end dialog\r\n"); fflush(fp_debug); } // /* New pannel */ if (result) { // erreur? strcpybuff(end_mirror_msg,LANG(LANG_F19 /*"A problem occured during the mirror\n \"","Un problËme est survenu pendant le miroir\n \""*/)); strcatbuff(end_mirror_msg,"\""); strcatbuff(end_mirror_msg,hts_errmsg()); strcatbuff(end_mirror_msg,"\""); strcatbuff(end_mirror_msg,LANG(LANG_F20 /*"\" \nDuring:\n ","\" \nDurant:\n "*/)); strcatbuff(end_mirror_msg,"\""); strcatbuff(end_mirror_msg,LINE_back); strcatbuff(end_mirror_msg,"\""); strcatbuff(end_mirror_msg,LANG(LANG_F21 /*"\nSee the log file if necessary.\n\nClick OK to quit WinHTTrack.\n\nThanks for using WinHTTrack!","\nVoir le fichier log au besoin\n\nCliquez sur OK pour quitter WinHTTrack\n\nMerci d'utiliser WinHTTrack."*/)); //AfxMessageBox(s,MB_OK+MB_ICONINFORMATION); } else { strcpybuff(end_mirror_msg,LANG(LANG_F22 /*"The mirror is finished.\nClick OK to quit WinHTTrack.\nSee log file(s) if necessary to ensure that everything is OK.\n\nThanks for using WinHTTrack!","Le miroir est terminÈ\nCliquez sur OK pour quitter WinHTTrack\nVoir au besoin les fichiers d'audit pour vÈrifier que tout s'est bien passÈ\n\nMerci d'utiliser WinHTTrack!"*/)); //AfxMessageBox("The mirror is finished.\nClic OK to quit WinHTTrack.\nSee log file(s) if necessary to ensure that everything is OK.\n\nThanks for using WinHTTrack!",MB_OK+MB_ICONINFORMATION); // ShellExecute(0,"open",,"","",); } #if USE_RAS // erreur ras if (connected == -1) if ((int) strlen(connected_err) > 0) strcpybuff(end_mirror_msg,connected_err); #endif { char pathlog[HTS_URLMAXSIZE*2]; strcpybuff(pathlog,dialog0->GetPath()); Ciplog form; if (strlen(pathlog)>0) if ((pathlog[strlen(pathlog)-1]!='/') && (pathlog[strlen(pathlog)-1]!='\\')) strcatbuff(pathlog,"/"); // fichier log existe ou on est tÈlÈcommandÈ par un ! if ( (fsize(fconcat(pathlog,"hts-err.txt")))>0) { strcatbuff(end_mirror_msg,LANG(LANG_F23 /*"\n\nTip: Click [View log file] to see warning or error messages","\n\nConseil: [Voir fichiers log] pour voir les erreurs et messages"*/)); } } //this_Cinfoend->m_infoend = msg; inprogress->SendMessage(WM_USER + 4); // avertir if (fp_debug) { fprintf(fp_debug,"DoModal end dialog, waiting\r\n"); fflush(fp_debug); } /* if (info.DoModal() == IDC_NewProject) { // relancer programme! // copie de onnewproject() de wid1:: CWinApp* pApp = AfxGetApp(); CString name = pApp->m_pszHelpFilePath; name=name.Left(name.GetLength()-4); name += ".EXE"; ShellExecute(NULL,"open",name,"","",SW_RESTORE); } */ if (fp_debug) { fprintf(fp_debug,"Final info OK, leaving..\r\n"); fflush(fp_debug); } } else { } } // int LANG_T(int); // char* LANG(char* english,char* francais); /* interface lang - lang_string="stringlang0\nstringlang1\n..laststring" */ void SetCombo(CWnd* _this,int id,char* lang_string) { CComboBox* combo = (CComboBox*) _this->GetDlgItem(id); CString st=lang_string; st.TrimLeft(); st.TrimRight(); if (combo) { st+="\n"; /* end */ combo->ResetContent(); while(st.GetLength()) { int pos=st.Find('\n'); CString item=st.Left(pos); st=st.Mid(pos+1); item.TrimLeft(); item.TrimRight(); if (item.GetLength()) combo->AddString(item); } } } // Ecriture profiles char* profile_code(char* from) { static char buff[65535]; int i; int j; for(i=0,j=0;i<(int) strlen(from);i++) { switch(from[i]) { case '%': buff[j++]='%'; buff[j++]='%'; break; case '=': buff[j++]='%'; buff[j++]='3'; buff[j++]='d'; break; case 13: buff[j++]='%'; buff[j++]='0'; buff[j++]='d'; break; case 10: buff[j++]='%'; buff[j++]='0'; buff[j++]='a'; break; case 9: buff[j++]='%'; buff[j++]='0'; buff[j++]='9'; break; default: buff[j++]=from[i]; break; } } buff[j++]='\0'; return buff; } char* profile_decode(char* from) { static char buff[2048]; int i; int j; for(i=0,j=0;j<(int) strlen(from);i++) { // oui oui if (from[j]=='%') { if (from[j+1]=='%') { buff[i]='%'; j+=2; } else { if (strncmp(from+j+1,"0d",2)==0) buff[i]=13; else if (strncmp(from+j+1,"0a",2)==0) buff[i]=10; else if (strncmp(from+j+1,"09",2)==0) buff[i]=9; else if (strncmp(from+j+1,"3d",2)==0) buff[i]='='; else buff[i]=' '; j+=3; } } else buff[i]=from[j++]; } buff[i++]='\0'; return buff; } // // Ecriture/Lecture profiles int MyWriteProfileInt(CString path,CString dummy,CString name,int value) { if (path.IsEmpty()) { CWinApp* pApp = AfxGetApp(); pApp->WriteProfileInt(dummy,name,value); } else if (path=="<mem>") { // buffer tmpm.setInt(name,value); return 0; } else if (path=="<tmp>") { // fichier temporaire commun if (tmpf) { return MyWriteProfileIntFile(tmpf,dummy,name,value); } } else { FILE* fp = fopen(path,"ab"); if (fp) { int r=MyWriteProfileIntFile(fp,dummy,name,value); /* fprintf(fp,"%s=%d\x0d\x0a",name,value); */ fclose(fp); return r; } } return 0; } int MyWriteProfileIntFile(FILE* fp,CString dummy,CString name,int value) { if (fp) { fprintf(fp,"%s=%d\x0d\x0a",name,value); } return 0; } int MyWriteProfileString(CString path,CString dummy,CString name,CString value) { if (path.IsEmpty()) { CWinApp* pApp = AfxGetApp(); char *tempo; tempo=(char*) malloc(strlen(value)+1); if (tempo) { strcpybuff(tempo,value); pApp->WriteProfileString(dummy,name,profile_code(tempo)); } else return -1; // error } else if (path=="<mem>") { // buffer tmpm.setString(name,value); return 0; } else if (path=="<tmp>") { // fichier temporaire commun if (tmpf) { return MyWriteProfileStringFile(tmpf,dummy,name,value); } } else { FILE* fp = fopen(path,"ab"); if (fp) { int r=MyWriteProfileStringFile(fp,dummy,name,value); /* char *tempo; tempo=(char*) malloc(strlen(value)+1); if (tempo) { strcpybuff(tempo,value); fprintf(fp,"%s=%s\x0d\x0a",name,profile_code(tempo)); fclose(fp); free(tempo); } else return -1; // error */ fclose(fp); return r; } } return 0; } int MyWriteProfileStringFile(FILE* fp,CString dummy,CString name,CString value) { if (fp) { char *tempo; tempo=(char*) malloc(strlen(value)+1); if (tempo) { strcpybuff(tempo,value); fprintf(fp,"%s=%s\x0d\x0a",name,profile_code(tempo)); free(tempo); } else return -1; // error } return 0; } // // lecture int MyGetProfileInt(CString path,CString dummy,CString name,int value) { if (path.IsEmpty()) { CWinApp* pApp = AfxGetApp(); return pApp->GetProfileInt(dummy,name,value); } else if (path=="<mem>") { // buffer return tmpm.getInt(name,value); } else if (path=="<tmp>") { // fichier temporaire commun if (tmpf) { return MyGetProfileIntFile(tmpf,dummy,name,value); } else return value; } else { FILE* fp = fopen(path,"rb"); if (fp) { int r=MyGetProfileIntFile(fp,dummy,name,value); /* char srch[256]; sprintf(srch,"%s=",name); while(!feof(fp)) { char s[HTS_URLMAXSIZE*2]; linput(fp,s,1020); if (strncmp(s,srch,strlen(srch)) == 0) { // ligne reconnue int val; if (sscanf(s+strlen(srch),"%d",&val) == 1) return val; else return value; } } fclose(fp); return value; */ fclose(fp); return r; } else return value; } } int MyGetProfileIntFile(FILE* fp,CString dummy,CString name,int value) { if (fp) { char srch[256]; fseek(fp,0,SEEK_SET); sprintf(srch,"%s=",name); while(!feof(fp)) { char s[2048]; s[0]='\0'; linput(fp,s,2000); if (strlen(s)==0) // EOF return value; if (strncmp(s,srch,strlen(srch)) == 0) { // ligne reconnue int val; if (sscanf(s+strlen(srch),"%d",&val) == 1) return val; else return value; } } return value; } else return value; } CString MyGetProfileString(CString path,CString dummy,CString name,CString value) { if (path.IsEmpty()) { CWinApp* pApp = AfxGetApp(); char tempo[32768]; char value_default[32768]; strcpybuff(value_default,value); strcpybuff(tempo,pApp->GetProfileString(dummy,name,profile_code(value_default))); return profile_decode(tempo); } else if (path=="<mem>") { // buffer return tmpm.getString(name,value); } else if (path=="<tmp>") { // fichier temporaire commun if (tmpf) { return MyGetProfileStringFile(tmpf,dummy,name,value); } else return value; } else { FILE* fp = fopen(path,"rb"); if (fp) { CString st=MyGetProfileStringFile(fp,dummy,name,value); /* char srch[256]; sprintf(srch,"%s",name); strcatbuff(srch,"="); while(!feof(fp)) { char s[32768]; linput(fp,s,32000); if (strncmp(s,srch,strlen(srch)) == 0) { // ligne reconnue return profile_decode(s+strlen(srch)); } } fclose(fp); return value; */ fclose(fp); return st; } else return value; } } CString MyGetProfileStringFile(FILE* fp,CString dummy,CString name,CString value) { if (fp) { char srch[256]; fseek(fp,0,SEEK_SET); sprintf(srch,"%s",name); strcatbuff(srch,"="); while(!feof(fp)) { char s[32768]; s[0]='\0'; linput(fp,s,32000); if (strlen(s)==0) // EOF return value; if (strncmp(s,srch,strlen(srch)) == 0) { // ligne reconnue return profile_decode(s+strlen(srch)); } } return value; } else return value; } // // Get_profile et Write_profile eux mÍmes // // path="" -> Ècrire dans la base (default) // path="<tmp>" -> Ècrire dans le fichier tempo commun // path="<mem>" -> Ècrire dans le buffer tempo commun // path="<null>" -> lire default (illÈgal en Ècriture) void Write_profile(CString path,int load_path) { CWaitCursor wait; CString strSection = "OptionsValues"; CString st; int n; // Fichier tempo ou fichier? if (path=="<tmp>") { // fichier temporaire if (tmpf) fclose(tmpf); tmpf=tmpfile(); if (!tmpf) return; } else if (path=="<mem>") { // buffer temporaire tmpm.deleteAll(); } else if (!(path.IsEmpty())) { FILE *fp=fopen(path,"wb"); if (fp) fclose(fp); } //if (dialog3.m_hWnd == NULL) { // pas initialisÈ if (maintab->m_hWnd == NULL) { // pas initialisÈ // checkboxes MyWriteProfileInt(path,strSection, "Near",maintab->m_option1.m_link); MyWriteProfileInt(path,strSection, "Test",maintab->m_option1.m_testall); MyWriteProfileInt(path,strSection, "ParseAll",maintab->m_option1.m_parseall); MyWriteProfileInt(path,strSection, "HTMLFirst",maintab->m_option1.m_htmlfirst); MyWriteProfileInt(path,strSection, "Cache",maintab->m_option3.m_cache); MyWriteProfileInt(path,strSection, "NoRecatch",maintab->m_option9.m_norecatch); MyWriteProfileInt(path,strSection, "Dos", ((maintab->m_option2.m_dos)?1:0) + (((maintab->m_option2.m_iso9660)?1:0)<<1) ); MyWriteProfileInt(path,strSection, "Index",maintab->m_option9.m_index); MyWriteProfileInt(path,strSection, "WordIndex",maintab->m_option9.m_index2); MyWriteProfileInt(path,strSection, "Log",maintab->m_option9.m_logf); MyWriteProfileInt(path,strSection, "RemoveTimeout",maintab->m_option4.m_remt); MyWriteProfileInt(path,strSection, "RemoveRateout",maintab->m_option4.m_rems); MyWriteProfileInt(path,strSection, "FollowRobotsTxt",maintab->m_option8.m_robots); MyWriteProfileInt(path,strSection, "NoErrorPages",maintab->m_option2.m_errpage); MyWriteProfileInt(path,strSection, "NoExternalPages",maintab->m_option2.m_external); MyWriteProfileInt(path,strSection, "NoPwdInPages",maintab->m_option2.m_hidepwd); MyWriteProfileInt(path,strSection, "NoQueryStrings",maintab->m_option2.m_hidequery); MyWriteProfileInt(path,strSection, "NoPurgeOldFiles",maintab->m_option2.m_nopurge); MyWriteProfileInt(path,strSection, "Cookies",maintab->m_option8.m_cookies); MyWriteProfileInt(path,strSection, "CheckType",maintab->m_option8.m_checktype); MyWriteProfileInt(path,strSection, "ParseJava",maintab->m_option8.m_parsejava); MyWriteProfileInt(path,strSection, "HTTP10",maintab->m_option8.m_http10); MyWriteProfileInt(path,strSection, "TolerantRequests",maintab->m_option8.m_toler); MyWriteProfileInt(path,strSection, "UpdateHack",maintab->m_option8.m_updhack); MyWriteProfileInt(path,strSection, "StoreAllInCache",maintab->m_option9.m_Cache2); MyWriteProfileInt(path,strSection, "LogType",maintab->m_option9.m_logtype); MyWriteProfileInt(path,strSection, "UseHTTPProxyForFTP",maintab->m_option10.m_ftpprox); // menus MyWriteProfileInt(path,strSection, "Build",maintab->m_option2.m_build); MyWriteProfileInt(path,strSection, "PrimaryScan",maintab->m_option3.m_filter); MyWriteProfileInt(path,strSection, "Travel",maintab->m_option3.m_travel); MyWriteProfileInt(path,strSection, "GlobalTravel",maintab->m_option3.m_travel2); MyWriteProfileInt(path,strSection, "RewriteLinks",maintab->m_option3.m_travel3); MyWriteProfileString(path,strSection, "BuildString",maintab->m_option2.Bopt.m_BuildString); // champs MyWriteProfileString(path,strSection, "MaxHtml",maintab->m_option5.m_maxhtml); MyWriteProfileString(path,strSection, "MaxOther",maintab->m_option5.m_othermax); MyWriteProfileString(path,strSection, "MaxAll",maintab->m_option5.m_sizemax); MyWriteProfileString(path,strSection, "MaxWait",maintab->m_option5.m_pausebytes); MyWriteProfileString(path,strSection, "Sockets",maintab->m_option4.m_connexion); MyWriteProfileString(path,strSection, "Retry",maintab->m_option4.m_retry); MyWriteProfileString(path,strSection, "MaxTime",maintab->m_option5.m_maxtime); MyWriteProfileString(path,strSection, "TimeOut",maintab->m_option4.m_timeout); MyWriteProfileString(path,strSection, "RateOut",maintab->m_option4.m_rate); MyWriteProfileString(path,strSection, "UserID",maintab->m_option6.m_user); MyWriteProfileString(path,strSection, "Footer",maintab->m_option6.m_footer); MyWriteProfileString(path,strSection, "MaxRate",maintab->m_option5.m_maxrate); MyWriteProfileString(path,strSection, "WildCardFilters",maintab->m_option7.m_url2); MyWriteProfileString(path,strSection, "Proxy",maintab->m_option10.m_proxy); MyWriteProfileString(path,strSection, "Port",maintab->m_option10.m_port); MyWriteProfileString(path,strSection, "Depth",maintab->m_option5.m_depth); MyWriteProfileString(path,strSection, "ExtDepth",maintab->m_option5.m_depth2); MyWriteProfileString(path,strSection, "MaxConn",maintab->m_option5.m_maxconn); MyWriteProfileString(path,strSection, "MaxLinks",maintab->m_option5.m_maxlinks); // 11 MyWriteProfileString(path,strSection, "MIMEDefsExt1",maintab->m_option11.m_ext1); MyWriteProfileString(path,strSection, "MIMEDefsExt2",maintab->m_option11.m_ext2); MyWriteProfileString(path,strSection, "MIMEDefsExt3",maintab->m_option11.m_ext3); MyWriteProfileString(path,strSection, "MIMEDefsExt4",maintab->m_option11.m_ext4); MyWriteProfileString(path,strSection, "MIMEDefsExt5",maintab->m_option11.m_ext5); MyWriteProfileString(path,strSection, "MIMEDefsExt6",maintab->m_option11.m_ext6); MyWriteProfileString(path,strSection, "MIMEDefsExt7",maintab->m_option11.m_ext7); MyWriteProfileString(path,strSection, "MIMEDefsExt8",maintab->m_option11.m_ext8); MyWriteProfileString(path,strSection, "MIMEDefsMime1",maintab->m_option11.m_mime1); MyWriteProfileString(path,strSection, "MIMEDefsMime2",maintab->m_option11.m_mime2); MyWriteProfileString(path,strSection, "MIMEDefsMime3",maintab->m_option11.m_mime3); MyWriteProfileString(path,strSection, "MIMEDefsMime4",maintab->m_option11.m_mime4); MyWriteProfileString(path,strSection, "MIMEDefsMime5",maintab->m_option11.m_mime5); MyWriteProfileString(path,strSection, "MIMEDefsMime6",maintab->m_option11.m_mime6); MyWriteProfileString(path,strSection, "MIMEDefsMime7",maintab->m_option11.m_mime7); MyWriteProfileString(path,strSection, "MIMEDefsMime8",maintab->m_option11.m_mime8); } else { // checkboxes // 1 n=maintab->m_option1.IsDlgButtonChecked(IDC_link); MyWriteProfileInt(path,strSection,"Near", n); n=maintab->m_option1.IsDlgButtonChecked(IDC_testall); MyWriteProfileInt(path,strSection,"Test", n); n=maintab->m_option1.IsDlgButtonChecked(IDC_parseall); MyWriteProfileInt(path,strSection,"ParseAll", n); n=maintab->m_option1.IsDlgButtonChecked(IDC_htmlfirst); MyWriteProfileInt(path,strSection,"HTMLFirst", n); // 2 n=maintab->m_option3.IsDlgButtonChecked(IDC_Cache); MyWriteProfileInt(path,strSection,"Cache", n); n=maintab->m_option2.IsDlgButtonChecked(IDC_norecatch); MyWriteProfileInt(path,strSection,"NoRecatch", n); n = ((maintab->m_option2.IsDlgButtonChecked(IDC_dos))?1:0) + ((maintab->m_option2.IsDlgButtonChecked(IDC_iso9660)?1:0)<<1); MyWriteProfileInt(path,strSection,"Dos", n); n=maintab->m_option2.IsDlgButtonChecked(IDC_index); MyWriteProfileInt(path,strSection,"Index", n); n=maintab->m_option2.IsDlgButtonChecked(IDC_index2); MyWriteProfileInt(path,strSection,"WordIndex", n); n=maintab->m_option2.IsDlgButtonChecked(IDC_logf); MyWriteProfileInt(path,strSection,"Log", n); n=maintab->m_option2.IsDlgButtonChecked(IDC_errpage); MyWriteProfileInt(path,strSection,"NoErrorPages", n); n=maintab->m_option2.IsDlgButtonChecked(IDC_hidepwd); MyWriteProfileInt(path,strSection,"NoPwdInPages", n); n=maintab->m_option2.IsDlgButtonChecked(IDC_hidequery); MyWriteProfileInt(path,strSection,"NoQueryStrings", n); n=maintab->m_option2.IsDlgButtonChecked(IDC_external); MyWriteProfileInt(path,strSection,"NoExternalPages", n); n=maintab->m_option2.IsDlgButtonChecked(IDC_nopurge); MyWriteProfileInt(path,strSection,"NoPurgeOldFiles", n); if ((n=maintab->m_option2.m_ctl_build.GetCurSel()) != CB_ERR) MyWriteProfileInt(path,strSection, "Build", n); st = maintab->m_option2.Bopt.m_BuildString; if (st.GetLength()>0) MyWriteProfileString(path,strSection, "BuildString",st); // 3 // menus if ((n=maintab->m_option3.m_ctl_filter.GetCurSel()) != CB_ERR) MyWriteProfileInt(path,strSection, "PrimaryScan", n); if ((n=maintab->m_option3.m_ctl_travel.GetCurSel()) != CB_ERR) MyWriteProfileInt(path,strSection, "Travel", n); if ((n=maintab->m_option3.m_ctl_travel2.GetCurSel()) != CB_ERR) MyWriteProfileInt(path,strSection, "GlobalTravel", n); if ((n=maintab->m_option3.m_ctl_travel3.GetCurSel()) != CB_ERR) MyWriteProfileInt(path,strSection, "RewriteLinks", n); // maintab->m_option8.GetDlgItemText(IDC_robots,st); MyWriteProfileString(path,strSection, "FollowRobotsTxt", st); // 4 maintab->m_option4.GetDlgItemText(IDC_connexion,st); MyWriteProfileString(path,strSection, "Sockets", st); maintab->m_option4.GetDlgItemText(IDC_timeout,st); MyWriteProfileString(path,strSection, "TimeOut", st); n=maintab->m_option4.IsDlgButtonChecked(IDC_remt); MyWriteProfileInt(path,strSection,"RemoveTimeout", n); maintab->m_option4.GetDlgItemText(IDC_retry,st); MyWriteProfileString(path,strSection, "Retry", st); maintab->m_option4.GetDlgItemText(IDC_rate,st); MyWriteProfileString(path,strSection, "RateOut", st); n=maintab->m_option4.IsDlgButtonChecked(IDC_rems); MyWriteProfileInt(path,strSection,"RemoveRateout", n); // 5 maintab->m_option5.GetDlgItemText(IDC_maxhtml,st); MyWriteProfileString(path,strSection, "MaxHtml", st); maintab->m_option5.GetDlgItemText(IDC_othermax,st); MyWriteProfileString(path,strSection, "MaxOther", st); maintab->m_option5.GetDlgItemText(IDC_sizemax,st); MyWriteProfileString(path,strSection, "MaxAll", st); maintab->m_option5.GetDlgItemText(IDC_pausebytes,st); MyWriteProfileString(path,strSection, "MaxWait", st); maintab->m_option5.GetDlgItemText(IDC_maxtime,st); MyWriteProfileString(path,strSection, "MaxTime", st); maintab->m_option5.GetDlgItemText(IDC_maxrate,st); MyWriteProfileString(path,strSection, "MaxRate", st); maintab->m_option5.GetDlgItemText(IDC_depth,st); MyWriteProfileString(path,strSection,"Depth",st); maintab->m_option5.GetDlgItemText(IDC_depth2,st); MyWriteProfileString(path,strSection,"ExtDepth",st); maintab->m_option5.GetDlgItemText(IDC_maxconn,st); MyWriteProfileString(path,strSection, "MaxConn", st); maintab->m_option5.GetDlgItemText(IDC_maxlinks,st); MyWriteProfileString(path,strSection, "MaxLinks", st); // 6 maintab->m_option6.GetDlgItemText(IDC_user,st); MyWriteProfileString(path,strSection, "UserID", st); maintab->m_option6.GetDlgItemText(IDC_footer,st); MyWriteProfileString(path,strSection, "Footer", st); // 7 maintab->m_option7.GetDlgItemText(IDC_URL2,st); MyWriteProfileString(path,strSection, "WildCardFilters", st); // 8 maintab->m_option8.GetDlgItemText(IDC_cookies,st); MyWriteProfileString(path,strSection, "Cookies", st); maintab->m_option8.GetDlgItemText(IDC_checktype,st); MyWriteProfileString(path,strSection, "CheckType", st); n=maintab->m_option8.IsDlgButtonChecked(IDC_parsejava); MyWriteProfileInt(path,strSection, "ParseJava", n); n=maintab->m_option8.IsDlgButtonChecked(IDC_http10); MyWriteProfileInt(path,strSection, "HTTP10", n); n=maintab->m_option8.IsDlgButtonChecked(IDC_toler); MyWriteProfileInt(path,strSection, "TolerantRequests", n); n=maintab->m_option8.IsDlgButtonChecked(IDC_updhack); MyWriteProfileInt(path,strSection, "UpdateHack", n); // 9 maintab->m_option9.GetDlgItemText(IDC_Cache2,st); MyWriteProfileString(path,strSection, "StoreAllInCache", st); maintab->m_option9.GetDlgItemText(IDC_logtype,st); MyWriteProfileString(path,strSection, "LogType", st); // 10 maintab->m_option10.GetDlgItemText(IDC_prox,st); MyWriteProfileString(path,strSection,"Proxy",st); maintab->m_option10.GetDlgItemText(IDC_proxport,st); MyWriteProfileString(path,strSection,"Port",st); n=maintab->m_option10.IsDlgButtonChecked(IDC_ftpprox); MyWriteProfileInt(path,strSection,"UseHTTPProxyForFTP", n); // 11 maintab->m_option11.GetDlgItemText(IDC_ext1,st); MyWriteProfileString(path,strSection,"MIMEDefsExt1",st); maintab->m_option11.GetDlgItemText(IDC_ext2,st); MyWriteProfileString(path,strSection,"MIMEDefsExt2",st); maintab->m_option11.GetDlgItemText(IDC_ext3,st); MyWriteProfileString(path,strSection,"MIMEDefsExt3",st); maintab->m_option11.GetDlgItemText(IDC_ext4,st); MyWriteProfileString(path,strSection,"MIMEDefsExt4",st); maintab->m_option11.GetDlgItemText(IDC_ext5,st); MyWriteProfileString(path,strSection,"MIMEDefsExt5",st); maintab->m_option11.GetDlgItemText(IDC_ext6,st); MyWriteProfileString(path,strSection,"MIMEDefsExt6",st); maintab->m_option11.GetDlgItemText(IDC_ext7,st); MyWriteProfileString(path,strSection,"MIMEDefsExt7",st); maintab->m_option11.GetDlgItemText(IDC_ext8,st); MyWriteProfileString(path,strSection,"MIMEDefsExt8",st); maintab->m_option11.GetDlgItemText(IDC_mime1,st); MyWriteProfileString(path,strSection,"MIMEDefsMime1",st); maintab->m_option11.GetDlgItemText(IDC_mime2,st); MyWriteProfileString(path,strSection,"MIMEDefsMime2",st); maintab->m_option11.GetDlgItemText(IDC_mime3,st); MyWriteProfileString(path,strSection,"MIMEDefsMime3",st); maintab->m_option11.GetDlgItemText(IDC_mime4,st); MyWriteProfileString(path,strSection,"MIMEDefsMime4",st); maintab->m_option11.GetDlgItemText(IDC_mime5,st); MyWriteProfileString(path,strSection,"MIMEDefsMime5",st); maintab->m_option11.GetDlgItemText(IDC_mime6,st); MyWriteProfileString(path,strSection,"MIMEDefsMime6",st); maintab->m_option11.GetDlgItemText(IDC_mime7,st); MyWriteProfileString(path,strSection,"MIMEDefsMime7",st); maintab->m_option11.GetDlgItemText(IDC_mime8,st); MyWriteProfileString(path,strSection,"MIMEDefsMime8",st); } // liens, jokers etc. si mirror merge if (!(path.IsEmpty())) { if (dialog1->m_hWnd == NULL) { // pas initialisÈ //MyWriteProfileString(path,strSection,"CurrentDepth",dialog1->m_depth); MyWriteProfileString(path,strSection,"CurrentUrl",dialog1->m_urls); if (dialog1->m_todo >= 0) MyWriteProfileInt(path, strSection,"CurrentAction", dialog1->m_todo); // MyWriteProfileString(path,strSection,"CurrentURLList",dialog1->m_filelist); //if (load_path) { //MyWriteProfileString(path,strSection,"CurrentPath1",dialog0->GetPath()); //MyWriteProfileString(path,strSection,"CurrentPath2",dialog0->GetPath()); //} } else { //dialog1->GetDlgItemText(IDC_depth,st); //MyWriteProfileString(path,strSection,"CurrentDepth",st); dialog1->GetDlgItemText(IDC_URL,st); MyWriteProfileString(path,strSection,"CurrentUrl",st); if ((n=dialog1->m_ctl_todo.GetCurSel()) != CB_ERR) MyWriteProfileInt(path,strSection, "CurrentAction", n); // dialog1->GetDlgItemText(IDC_filelist,st); MyWriteProfileString(path,strSection,"CurrentURLList",st); // //if (load_path) { //dialog1->GetDlgItemText(IDC_pathlog,st); //MyWriteProfileString(path,strSection,"CurrentPath1",st); //dialog1->GetDlgItemText(IDC_pthmir,st); //MyWriteProfileString(path,strSection,"CurrentPath2",st); //} } } } // path="" -> lire dans la base (default) //if not exist: do not load anything but patches projname&co void Read_profile(CString path,int load_path) { CWaitCursor wait; CString strSection = "OptionsValues"; CString st; // VÈrification <tmp> if (path=="<tmp>") { // fichier temporaire if (!tmpf) return; else fflush(tmpf); } else if (path=="<null>") { // options par dÈfaut path="<mem>"; tmpm.deleteAll(); // effacer } else { int pos=path.ReverseFind('\\'); if (pos>=0) { CString dir=path.Left(pos); // enlever winprofile.ini pos=dir.ReverseFind('\\'); if (pos>=0) { dir=dir.Left(pos); // enlever hts-cache pos=dir.ReverseFind('\\'); if (pos>=0) { dialog0->m_projname=dir.Mid(pos+1); dialog0->m_projpath=dir.Left(pos); /* if (this_CWizTab) this_CWizTab->SetActivePage(2); // page 3 */ } } } } // checkboxes maintab->m_option1.m_link = MyGetProfileInt(path,strSection, "Near",0); maintab->m_option1.m_testall = MyGetProfileInt(path,strSection, "Test",0); maintab->m_option1.m_parseall = MyGetProfileInt(path,strSection, "ParseAll",1); maintab->m_option1.m_htmlfirst = MyGetProfileInt(path,strSection, "HTMLFirst",0); maintab->m_option3.m_cache = MyGetProfileInt(path,strSection, "Cache",1); maintab->m_option9.m_norecatch = MyGetProfileInt(path,strSection, "NoRecatch",0); maintab->m_option2.m_dos = (MyGetProfileInt(path,strSection, "Dos",0) & 1); maintab->m_option2.m_iso9660 = ((MyGetProfileInt(path,strSection, "Dos",0) & 2)>>1); maintab->m_option9.m_index = MyGetProfileInt(path,strSection, "Index",1); maintab->m_option9.m_index2 = MyGetProfileInt(path,strSection, "WordIndex",0); maintab->m_option9.m_logf = MyGetProfileInt(path,strSection, "Log",1); maintab->m_option4.m_remt = MyGetProfileInt(path,strSection, "RemoveTimeout",0); maintab->m_option4.m_rems = MyGetProfileInt(path,strSection, "RemoveRateout",0); maintab->m_option8.m_robots = MyGetProfileInt(path,strSection, "FollowRobotsTxt",2); maintab->m_option2.m_errpage = MyGetProfileInt(path,strSection, "NoErrorPages",0); maintab->m_option2.m_external = MyGetProfileInt(path,strSection, "NoExternalPages",0); maintab->m_option2.m_hidepwd = MyGetProfileInt(path,strSection, "NoPwdInPages",0); maintab->m_option2.m_hidequery = MyGetProfileInt(path,strSection, "NoQueryStrings",0); maintab->m_option2.m_nopurge = MyGetProfileInt(path,strSection, "NoPurgeOldFiles",0); maintab->m_option8.m_cookies = MyGetProfileInt(path,strSection, "Cookies",1); maintab->m_option8.m_checktype = MyGetProfileInt(path,strSection, "CheckType",1); maintab->m_option8.m_parsejava = MyGetProfileInt(path,strSection, "ParseJava",1); maintab->m_option8.m_toler = MyGetProfileInt(path,strSection, "TolerantRequests",0); maintab->m_option8.m_updhack = MyGetProfileInt(path,strSection, "UpdateHack",1); maintab->m_option8.m_http10 = MyGetProfileInt(path,strSection, "HTTP10",0); maintab->m_option9.m_Cache2 = MyGetProfileInt(path,strSection, "StoreAllInCache",0); maintab->m_option9.m_logtype = MyGetProfileInt(path,strSection, "LogType",0); // menus maintab->m_option2.m_build = MyGetProfileInt(path,strSection, "Build",0); maintab->m_option3.m_filter = MyGetProfileInt(path,strSection, "PrimaryScan",3); maintab->m_option3.m_travel = MyGetProfileInt(path,strSection, "Travel",1); maintab->m_option3.m_travel2 = MyGetProfileInt(path,strSection, "GlobalTravel",0); maintab->m_option3.m_travel3 = MyGetProfileInt(path,strSection, "RewriteLinks",0); maintab->m_option2.Bopt.m_BuildString = MyGetProfileString(path,strSection, "BuildString","%h%p/%n%q.%t"); // champs maintab->m_option5.m_maxhtml = MyGetProfileString(path,strSection, "MaxHtml"); maintab->m_option5.m_othermax= MyGetProfileString(path,strSection, "MaxOther"); maintab->m_option5.m_sizemax = MyGetProfileString(path,strSection, "MaxAll"); maintab->m_option5.m_pausebytes=MyGetProfileString(path,strSection, "MaxWait"); maintab->m_option4.m_connexion= MyGetProfileString(path,strSection, "Sockets"); maintab->m_option4.m_retry = MyGetProfileString(path,strSection, "Retry"); maintab->m_option5.m_maxtime = MyGetProfileString(path,strSection, "MaxTime"); maintab->m_option4.m_timeout = MyGetProfileString(path,strSection, "TimeOut"); maintab->m_option4.m_rate = MyGetProfileString(path,strSection, "RateOut"); maintab->m_option6.m_user = MyGetProfileString(path,strSection, "UserID","Mozilla/4.5 (compatible; HTTrack 3.0x; Windows 98)"); maintab->m_option6.m_footer = MyGetProfileString(path,strSection, "Footer",HTS_DEFAULT_FOOTER); maintab->m_option5.m_maxrate = MyGetProfileString(path,strSection, "MaxRate"); maintab->m_option5.m_maxconn = MyGetProfileString(path,strSection, "MaxConn"); maintab->m_option5.m_maxlinks = MyGetProfileString(path,strSection, "MaxLinks"); // 7 maintab->m_option7.m_url2 = MyGetProfileString(path,strSection, "WildCardFilters","+*.png +*.gif +*.jpg +*.css +*.js -ad.doubleclick.net/*"); // 10 maintab->m_option10.m_proxy = MyGetProfileString(path,strSection, "Proxy"); maintab->m_option10.m_port = MyGetProfileString(path,strSection, "Port"); maintab->m_option10.m_ftpprox = MyGetProfileInt(path,strSection, "UseHTTPProxyForFTP",1); // maintab->m_option5.m_depth = MyGetProfileString(path,strSection, "Depth"); maintab->m_option5.m_depth2 = MyGetProfileString(path,strSection, "ExtDepth"); // 11 maintab->m_option11.m_ext1 = MyGetProfileString(path,strSection, "MIMEDefsExt1", "php3,php,php2,asp,jsp,pl,cfm"); maintab->m_option11.m_ext2 = MyGetProfileString(path,strSection, "MIMEDefsExt2"); maintab->m_option11.m_ext3 = MyGetProfileString(path,strSection, "MIMEDefsExt3"); maintab->m_option11.m_ext4 = MyGetProfileString(path,strSection, "MIMEDefsExt4"); maintab->m_option11.m_ext5 = MyGetProfileString(path,strSection, "MIMEDefsExt5"); maintab->m_option11.m_ext6 = MyGetProfileString(path,strSection, "MIMEDefsExt6"); maintab->m_option11.m_ext7 = MyGetProfileString(path,strSection, "MIMEDefsExt7"); maintab->m_option11.m_ext8 = MyGetProfileString(path,strSection, "MIMEDefsExt8"); maintab->m_option11.m_mime1 = MyGetProfileString(path,strSection, "MIMEDefsMime1", "text/html"); maintab->m_option11.m_mime2 = MyGetProfileString(path,strSection, "MIMEDefsMime2"); maintab->m_option11.m_mime3 = MyGetProfileString(path,strSection, "MIMEDefsMime3"); maintab->m_option11.m_mime4 = MyGetProfileString(path,strSection, "MIMEDefsMime4"); maintab->m_option11.m_mime5 = MyGetProfileString(path,strSection, "MIMEDefsMime5"); maintab->m_option11.m_mime6 = MyGetProfileString(path,strSection, "MIMEDefsMime6"); maintab->m_option11.m_mime7 = MyGetProfileString(path,strSection, "MIMEDefsMime7"); maintab->m_option11.m_mime8 = MyGetProfileString(path,strSection, "MIMEDefsMime8"); //st = MyGetProfileString(path,strSection,"WildCardFilters"); //strcpybuff(buff_filtres,st); // liens, jokers etc. si mirror merge if (!(path.IsEmpty())) { if (dialog1->m_hWnd == NULL) { // pas initialisÈ //dialog1->m_depth = MyGetProfileString(path,strSection,"CurrentDepth"); dialog1->m_urls = MyGetProfileString(path,strSection,"CurrentUrl"); dialog1->m_todo = MyGetProfileInt(path,strSection,"CurrentAction",0); dialog1->m_filelist = MyGetProfileString(path,strSection,"CurrentURLList"); /* if (load_path) { CString st; st = MyGetProfileString(path,strSection,"CurrentPath1"); if (st != "") dialog1->m_pathlog = st; st = MyGetProfileString(path,strSection,"CurrentPath2"); if (st != "") dialog1->m_pathmir = st; } */ } else { //st = MyGetProfileString(path,strSection,"CurrentDepth"); //dialog1->SetDlgItemText(IDC_depth,st); st = MyGetProfileString(path,strSection,"CurrentUrl"); dialog1->SetDlgItemText(IDC_URL,st); int n = MyGetProfileInt(path,strSection,"CurrentAction",0); dialog1->m_ctl_todo.SetCurSel(n); st = MyGetProfileString(path,strSection,"CurrentURLList"); dialog1->SetDlgItemText(IDC_filelist,st); /* if (load_path) { st = MyGetProfileString(path,strSection,"CurrentPath1"); if (st != "") dialog1->SetDlgItemText(IDC_pathlog,st); st = MyGetProfileString(path,strSection,"CurrentPath2"); if (st != "") dialog1->SetDlgItemText(IDC_pthmir,st); } */ dialog1->Refresh(); } } } // Initialisation du RAS void InitRAS() { #if USE_RAS if (!LibRas) { LibRas=new CDynamicRAS(); if (LibRas->IsRASLoaded()) LibRasUse=1; else LibRasUse=0; } #endif } // Reconstruire index gÈnÈral! void Build_TopIndex(BOOL check_empty) { CWaitCursor wait; //if (toptemplate_header && toptemplate_body && toptemplate_footer) { { char path[HTS_URLMAXSIZE*2]; strcpybuff(path,CShellApp_app->end_path); /* Build top index */ hts_buildtopindex(path, ""); /* Check empty dirs and build .whtt */ // FILE* fpo=fopen(fconcat(path,"/index.html"),"wb"); //if (fpo) { { // verif_backblue(path); // gÈnÈrer gif // // Header //fprintf(fpo,toptemplate_header, // "<!-- Mirror and index made by HTTrack Website Copier/"HTTRACK_VERSION" "HTTRACK_AFF_AUTHORS" -->" // ); // chargement de la liste WIN32_FIND_DATA find; HANDLE h = FindFirstFile(CShellApp_app->end_path+"*.*",&find); if (h != INVALID_HANDLE_VALUE) { CString to_delete=""; do { if (!(find.dwFileAttributes & (FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN) )) if (strcmp(find.cFileName,"..")) if (strcmp(find.cFileName,".")) if (find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { int r; r=CheckDirInfo(CShellApp_app->end_path+find.cFileName); if ((r>=0) && (r<=3)) { /* vide, fichiers vides etc */ to_delete+=(CShellApp_app->end_path+find.cFileName+"\n"); } else { /* non vide */ char iname[HTS_URLMAXSIZE*2],iname2[HTS_URLMAXSIZE*2]; strcpybuff(iname,CShellApp_app->end_path); strcatbuff(iname,find.cFileName); strcatbuff(iname,"\\"); strcpybuff(iname2,iname); strcatbuff(iname,"index.html"); strcatbuff(iname2,"\\hts-cache\\winprofile.ini"); if (fexist(iname)) { char hname[HTS_URLMAXSIZE*2]; strcpybuff(hname,find.cFileName); escape_check_url(hname); // Body //fprintf(fpo,toptemplate_body, // hname, // find.cFileName // ); } if ((fexist(iname)) || (fexist(iname2)) ) { // vÈrifier existence de .whtt strcpybuff(iname,CShellApp_app->end_path); strcatbuff(iname,find.cFileName); strcatbuff(iname,".whtt"); if (!fexist(iname)) { FILE* fp=fopen(iname,"wb"); if (fp) fclose(fp); } } } } else { /* effacer .whtt qui ne pointent vers rien */ CString iname=CShellApp_app->end_path+find.cFileName; if (iname.Right(5).CompareNoCase(".whtt")==0) { CString rname=iname.Left(iname.GetLength()-5)+"\\index.html"; CString rname2=iname.Left(iname.GetLength()-5)+"\\hts-cache\\winprofile.ini"; if ( (!fexist((char*)LPCTSTR(rname))) && (!fexist((char*)LPCTSTR(rname2))) ) { remove(iname); } } } } while(FindNextFile(h,&find)); FindClose(h); if (check_empty) { while(to_delete.GetLength()>0) { int pos=to_delete.Find('\n'); if (pos) { CString path=to_delete.Left(pos); to_delete=to_delete.Mid(pos+1); CString str; str.Format(LANG_DELETEEMPTYCONF,path); if (AfxMessageBox(str,MB_OKCANCEL)==IDOK) { /* Èliminer au besoin le .whtt */ DeleteFile(path+".whtt"); if (!RemoveEmptyDir(path)) AfxMessageBox(LANG_ERRORDEL); } } else to_delete=""; } } } // Footer //fprintf(fpo,toptemplate_footer, // "<!-- Mirror and index made by HTTrack Website Copier/"HTTRACK_VERSION" "HTTRACK_AFF_AUTHORS" -->" // ); //fclose(fpo); } } /* if (toptemplate_header) freet(toptemplate_header); if (toptemplate_body) freet(toptemplate_body); if (toptemplate_footer) freet(toptemplate_footer); */ } /* -1 : error 0 : directory is empty 1 : empty directories inside 2 : empty files inside 3 : 1 + 2 4 : not empty */ int CheckDirInfo(CString path) { CWaitCursor wait; if (path.Right(1)!="\\") path+="\\"; // Pour FindFirstFile/FindNextFile WIN32_FIND_DATA find; HANDLE h = FindFirstFile(path+"*.*",&find); // accessible if (h!=INVALID_HANDLE_VALUE) { int return_code=0; do { if (!(find.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM )) { if (strcmp(find.cFileName,"..")) { if (strcmp(find.cFileName,".")) { if (find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { return_code|=1; int r=CheckDirInfo(path+find.cFileName); if (r==4) return_code=4; else return_code|=r; } else { return_code|=2; if ((find.nFileSizeLow) || (find.nFileSizeHigh)) return_code=4; } } } } } while(FindNextFile(h,&find) && !((return_code & 4)) ); FindClose(h); return return_code; } else return -1; } /* Remove Empty Dir */ BOOL RemoveEmptyDir(CString path) { CWaitCursor wait; SetCurrentDirectory("C:\\"); if (path.Right(1)!="\\") path+="\\"; // Pour FindFirstFile/FindNextFile WIN32_FIND_DATA find; HANDLE h = FindFirstFile(path+"*.*",&find); // accessible if (h!=INVALID_HANDLE_VALUE) { do { if (!(find.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM )) { if (strcmp(find.cFileName,"..")) { if (strcmp(find.cFileName,".")) { if (find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { if (!RemoveEmptyDir(path+find.cFileName)) { FindClose(h); return 0; } } else { if ((!find.nFileSizeLow) && (!find.nFileSizeHigh)) if (!DeleteFile(path+find.cFileName)) { FindClose(h); return 0; } } } } } } while(FindNextFile(h,&find)); FindClose(h); SetCurrentDirectory("C:\\"); return RemoveDirectory(path.Left(path.GetLength()-1)); } else return 0; return TRUE; }